OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget Class Reference
Inheritance diagram for Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget:
Collaboration diagram for Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget:

Public Types

using SelectFn = std::function<void(FlashforgeMaterialMapWidget*)>

Public Member Functions

 FlashforgeMaterialMapWidget (wxWindow *parent, int tool_id, const wxColour &color, const wxString &material_name, SelectFn on_select)
int tool_id () const
int selected_slot_id () const
bool is_slot_selected () const
wxString material_name () const
void set_enable_mapping (bool enable)
void set_slot_selection (int slot_id, const wxColour &slot_color)
void reset_slot ()
void update_popup_slots (const std::vector< Slic3r::FlashforgeMaterialSlot > &slots, const std::function< bool(const Slic3r::FlashforgeMaterialSlot &)> &matcher)
wxSize DoGetBestSize () const override

Private Member Functions

void on_left_down (wxMouseEvent &e)
void on_paint (wxPaintEvent &)

Private Attributes

int m_tool_id {-1}
wxColour m_color
wxString m_name
wxColour m_slot_color {wxColour("#DDDDDD")}
int m_slot_id {0}
bool m_selected {false}
bool m_mapping_enabled {true}
SelectFn m_select_fn
std::vector< Slic3r::FlashforgeMaterialSlot > m_slots_snapshot
std::function< bool(const Slic3r::FlashforgeMaterialSlot &)> m_matcher

Detailed Description

Member Typedef Documentation

◆ SelectFn

using Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::SelectFn = std::function<void(FlashforgeMaterialMapWidget*)>

Constructor & Destructor Documentation

◆ FlashforgeMaterialMapWidget()

Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::FlashforgeMaterialMapWidget ( wxWindow * parent,
int tool_id,
const wxColour & color,
const wxString & material_name,
SelectFn on_select )
inline
315 : wxPanel(parent, wxID_ANY)
317 , m_color(color)
318 , m_name(material_name.Strip())
319 , m_select_fn(std::move(on_select))
320 {
321 SetDoubleBuffered(true);
322 const wxSize size(FromDIP(72), FromDIP(58));
323 SetSize(size);
324 SetMinSize(size);
325 SetMaxSize(size);
326 Bind(wxEVT_PAINT, &FlashforgeMaterialMapWidget::on_paint, this);
327 Bind(wxEVT_LEFT_DOWN, &FlashforgeMaterialMapWidget::on_left_down, this);
328
329 }
void on_paint(wxPaintEvent &)
Definition PrintHostDialogs.cpp:393
void on_left_down(wxMouseEvent &e)
Definition PrintHostDialogs.cpp:373

References m_color, m_name, m_select_fn, m_tool_id, material_name(), on_left_down(), on_paint(), and tool_id().

Here is the call graph for this function:

Member Function Documentation

◆ DoGetBestSize()

wxSize Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::DoGetBestSize ( ) const
inlineoverride
368 {
369 return wxSize(FromDIP(72), FromDIP(58));
370 }

◆ is_slot_selected()

bool Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::is_slot_selected ( ) const
inline
333{ return m_slot_id > 0; }

References m_slot_id.

◆ material_name()

wxString Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::material_name ( ) const
inline
334{ return m_name; }

References m_name.

Referenced by FlashforgeMaterialMapWidget().

Here is the caller graph for this function:

◆ on_left_down()

void Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::on_left_down ( wxMouseEvent & e)
inlineprivate
374 {
376 return;
377
378 FlashforgeSlotDialog dlg(this, m_name);
379 dlg.update_slots(m_slots_snapshot, m_matcher);
380 m_selected = true;
381 Refresh();
382 if (dlg.ShowModal() == wxID_OK && dlg.has_selection()) {
383 m_slot_id = dlg.selected_slot_id();
384 m_slot_color = dlg.selected_color();
385 if (m_select_fn)
386 m_select_fn(this);
387 }
388 m_selected = false;
389 Refresh();
390 e.Skip();
391 }
std::function< bool(const Slic3r::FlashforgeMaterialSlot &)> m_matcher
Definition PrintHostDialogs.cpp:456
std::vector< Slic3r::FlashforgeMaterialSlot > m_slots_snapshot
Definition PrintHostDialogs.cpp:455

References Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotDialog::has_selection(), m_mapping_enabled, m_matcher, m_name, m_select_fn, m_selected, m_slot_color, m_slot_id, m_slots_snapshot, Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotDialog::selected_color(), Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotDialog::selected_slot_id(), Slic3r::GUI::DPIAware< P >::ShowModal(), Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotDialog::update_slots(), and Slic3r::GUI::wxMouseEvent.

Referenced by FlashforgeMaterialMapWidget().

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

◆ on_paint()

void Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::on_paint ( wxPaintEvent & )
inlineprivate
394 {
395 wxPaintDC dc(this);
396 std::unique_ptr<wxGraphicsContext> gc(wxGraphicsContext::Create(dc));
397 if (gc == nullptr)
398 return;
399
400 const wxSize size = GetSize();
401 const int half_h = size.y / 2;
402 gc->SetPen(*wxTRANSPARENT_PEN);
403 gc->SetBrush(wxBrush(m_color));
404 gc->DrawRoundedRectangle(0, 0, size.x, half_h, FromDIP(3));
405 gc->DrawRectangle(0, half_h - FromDIP(3), size.x, FromDIP(3));
406
407 gc->SetBrush(wxBrush(m_mapping_enabled ? m_slot_color : wxColour("#DDDDDD")));
408 gc->DrawRoundedRectangle(0, half_h, size.x, half_h, FromDIP(3));
409 gc->DrawRectangle(0, half_h, size.x, FromDIP(3));
410
411 if (m_selected) {
412 gc->SetPen(wxPen(wxColour("#00AE42"), FromDIP(2)));
413 gc->SetBrush(*wxTRANSPARENT_BRUSH);
414 gc->DrawRoundedRectangle(0, 0, size.x - FromDIP(1), size.y - FromDIP(1), FromDIP(3));
415 } else if (m_color.GetLuminance() > 0.95 || m_slot_color.GetLuminance() > 0.95) {
416 gc->SetPen(wxPen(wxColour("#ACACAC"), FromDIP(1)));
417 gc->SetBrush(*wxTRANSPARENT_BRUSH);
418 gc->DrawRoundedRectangle(0, 0, size.x - FromDIP(1), size.y - FromDIP(1), FromDIP(3));
419 }
420
421 dc.SetFont(::Label::Body_13);
422 dc.SetTextForeground(contrasting_text_color(m_color));
423 wxString top_text = m_name;
424 if (dc.GetTextExtent(top_text).x > size.x - FromDIP(10)) {
425 dc.SetFont(::Label::Body_10);
426 }
427 wxSize top_size = dc.GetTextExtent(top_text);
428 dc.DrawText(top_text, (size.x - top_size.x) / 2, (half_h - top_size.y) / 2);
429
430 dc.SetFont(::Label::Body_13);
431 dc.SetTextForeground(contrasting_text_color(m_slot_color));
432 const wxString bottom_text = m_slot_id > 0 ? wxString::Format("%d", m_slot_id) : "-";
433 const wxSize bottom_size = dc.GetTextExtent(bottom_text);
434 dc.DrawText(bottom_text, (size.x - bottom_size.x - FromDIP(10)) / 2, half_h + (half_h - bottom_size.y) / 2);
435
436 wxPoint pts[3] = {
437 wxPoint(size.x - FromDIP(18), half_h + half_h / 2 - FromDIP(2)),
438 wxPoint(size.x - FromDIP(10), half_h + half_h / 2 - FromDIP(2)),
439 wxPoint(size.x - FromDIP(14), half_h + half_h / 2 + FromDIP(3))
440 };
441 dc.SetBrush(wxBrush(contrasting_text_color(m_slot_color)));
442 dc.SetPen(*wxTRANSPARENT_PEN);
443 dc.DrawPolygon(3, pts);
444 }
static wxFont Body_13
Definition Label.hpp:54
static wxFont Body_10
Definition Label.hpp:56
wxColour contrasting_text_color(const wxColour &background)
Definition PrintHostDialogs.cpp:96

References Label::Body_10, Label::Body_13, Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::contrasting_text_color(), m_color, m_mapping_enabled, m_name, m_selected, m_slot_color, and m_slot_id.

Referenced by FlashforgeMaterialMapWidget().

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

◆ reset_slot()

void Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::reset_slot ( )
inline
355 {
356 m_slot_id = 0;
357 m_slot_color = wxColour("#DDDDDD");
358 Refresh();
359 }

References m_slot_color, and m_slot_id.

Referenced by set_enable_mapping().

Here is the caller graph for this function:

◆ selected_slot_id()

int Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::selected_slot_id ( ) const
inline
332{ return m_slot_id; }

References m_slot_id.

◆ set_enable_mapping()

void Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::set_enable_mapping ( bool enable)
inline
337 {
338 if (m_mapping_enabled == enable)
339 return;
340 m_mapping_enabled = enable;
341 if (!enable)
342 reset_slot();
343 Enable(enable);
344 Refresh();
345 }
@ Enable
Definition Config.hpp:245

References Slic3r::Enable, m_mapping_enabled, and reset_slot().

Here is the call graph for this function:

◆ set_slot_selection()

void Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::set_slot_selection ( int slot_id,
const wxColour & slot_color )
inline
348 {
349 m_slot_id = slot_id;
350 m_slot_color = slot_color;
351 Refresh();
352 }

References m_slot_color, and m_slot_id.

◆ tool_id()

int Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::tool_id ( ) const
inline
331{ return m_tool_id; }

References m_tool_id.

Referenced by FlashforgeMaterialMapWidget().

Here is the caller graph for this function:

◆ update_popup_slots()

void Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::update_popup_slots ( const std::vector< Slic3r::FlashforgeMaterialSlot > & slots,
const std::function< bool(const Slic3r::FlashforgeMaterialSlot &)> & matcher )
inline
362 {
363 m_slots_snapshot = slots;
364 m_matcher = matcher;
365 }

References m_matcher, and m_slots_snapshot.

Member Data Documentation

◆ m_color

wxColour Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::m_color
private

◆ m_mapping_enabled

bool Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::m_mapping_enabled {true}
private
453{true};

Referenced by on_left_down(), on_paint(), and set_enable_mapping().

◆ m_matcher

std::function<bool(const Slic3r::FlashforgeMaterialSlot&)> Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::m_matcher
private

Referenced by on_left_down(), and update_popup_slots().

◆ m_name

wxString Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::m_name
private

◆ m_select_fn

SelectFn Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::m_select_fn
private

◆ m_selected

bool Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::m_selected {false}
private
452{false};

Referenced by on_left_down(), and on_paint().

◆ m_slot_color

wxColour Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::m_slot_color {wxColour("#DDDDDD")}
private
450{wxColour("#DDDDDD")};

Referenced by on_left_down(), on_paint(), reset_slot(), and set_slot_selection().

◆ m_slot_id

int Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::m_slot_id {0}
private

◆ m_slots_snapshot

std::vector<Slic3r::FlashforgeMaterialSlot> Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::m_slots_snapshot
private

Referenced by on_left_down(), and update_popup_slots().

◆ m_tool_id

int Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeMaterialMapWidget::m_tool_id {-1}
private
447{-1};

Referenced by FlashforgeMaterialMapWidget(), and tool_id().


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