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

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

Inheritance diagram for Slic3r::GUI::AmsRMGroup:
Collaboration diagram for Slic3r::GUI::AmsRMGroup:

Public Member Functions

 AmsRMGroup (wxWindow *parent, std::map< std::string, wxColour > group_info, wxString mname, wxString group_index)
 ~AmsRMGroup ()
void set_index (std::string index)
void paintEvent (wxPaintEvent &evt)
void render (wxDC &dc)
void doRender (wxDC &dc)
void on_mouse_move (wxMouseEvent &evt)
double GetAngle (wxPoint pointA, wxPoint pointB)
wxPoint CalculateEndpoint (const wxPoint &startPoint, int angle, int length)

Private Attributes

std::map< std::string, wxColour > m_group_info
std::string m_selected_index
ScalableBitmap backup_current_use_white
ScalableBitmap backup_current_use_black
ScalableBitmap bitmap_backup_tips_0
ScalableBitmap bitmap_backup_tips_1
ScalableBitmap bitmap_editable
ScalableBitmap bitmap_bg
ScalableBitmap bitmap_editable_light
wxString m_material_name
wxString m_group_index

Detailed Description

Constructor & Destructor Documentation

◆ AmsRMGroup()

Slic3r::GUI::AmsRMGroup::AmsRMGroup ( wxWindow * parent,
std::map< std::string, wxColour > group_info,
wxString mname,
wxString group_index )
2392{
2393#ifdef __WINDOWS__
2394 SetDoubleBuffered(true);
2395#endif //__WINDOWS__
2396 m_group_info.clear();
2397 m_group_info = group_info;
2398 m_material_name = mname;
2399 m_group_index = group_index;
2400
2401 wxWindow::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize);
2402 SetSize(wxSize(FromDIP(166), FromDIP(166)));
2403 SetMinSize(wxSize(FromDIP(166), FromDIP(166)));
2404 SetMaxSize(wxSize(FromDIP(166), FromDIP(166)));
2405 SetBackgroundColour(*wxWHITE);
2406
2407 backup_current_use_white = ScalableBitmap(this, "backup_current_use1",8);
2408 backup_current_use_black = ScalableBitmap(this, "backup_current_use2", 8);
2409 bitmap_backup_tips_0 = ScalableBitmap(this, "backup_tips_img", 90);
2410 bitmap_editable = ScalableBitmap(this, "ams_editable", 14);
2411 bitmap_bg = ScalableBitmap(this, "back_up_ts_bk", 162);
2412 bitmap_editable_light = ScalableBitmap(this, "ams_editable_light", 14);
2413
2414 Bind(wxEVT_PAINT, &AmsRMGroup::paintEvent, this);
2415 Bind(wxEVT_LEFT_DOWN, &AmsRMGroup::on_mouse_move, this);
2416 wxGetApp().UpdateDarkUI(this);
2417}
ScalableBitmap backup_current_use_white
Definition AmsMappingPopup.hpp:534
wxString m_material_name
Definition AmsMappingPopup.hpp:541
void paintEvent(wxPaintEvent &evt)
Definition AmsMappingPopup.cpp:2468
void on_mouse_move(wxMouseEvent &evt)
Definition AmsMappingPopup.cpp:2433
std::map< std::string, wxColour > m_group_info
Definition AmsMappingPopup.hpp:532
wxString m_group_index
Definition AmsMappingPopup.hpp:542
ScalableBitmap backup_current_use_black
Definition AmsMappingPopup.hpp:535
ScalableBitmap bitmap_backup_tips_0
Definition AmsMappingPopup.hpp:536
ScalableBitmap bitmap_bg
Definition AmsMappingPopup.hpp:539
ScalableBitmap bitmap_editable_light
Definition AmsMappingPopup.hpp:540
ScalableBitmap bitmap_editable
Definition AmsMappingPopup.hpp:538

References backup_current_use_black, backup_current_use_white, bitmap_backup_tips_0, bitmap_bg, bitmap_editable, bitmap_editable_light, m_group_index, m_group_info, m_material_name, on_mouse_move(), and paintEvent().

Here is the call graph for this function:

◆ ~AmsRMGroup()

Slic3r::GUI::AmsRMGroup::~AmsRMGroup ( )
inline
520{};

Member Function Documentation

◆ CalculateEndpoint()

wxPoint Slic3r::GUI::AmsRMGroup::CalculateEndpoint ( const wxPoint & startPoint,
int angle,
int length )
2496{
2497 int endX = startPoint.x + length * cos(angle * M_PI / 180);
2498 int endY = startPoint.y + length * sin(angle * M_PI / 180);
2499 return wxPoint(endX, endY);
2500}
#define M_PI
Definition ExtrusionSimulator.cpp:31
double length(const Points &pts)
Definition MultiPoint.hpp:181
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:138

References Slic3r::angle(), Slic3r::length(), and M_PI.

Referenced by doRender().

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

◆ doRender()

void Slic3r::GUI::AmsRMGroup::doRender ( wxDC & dc)
2503{
2504 wxSize size = GetSize();
2505
2506 float center_mask_radius = FromDIP(52);
2507 float selected_radius = FromDIP(53);
2508
2509 float ev_angle = 360.0 / m_group_info.size();
2510 float startAngle = 0.0;
2511 float endAngle = 0.0;
2512
2513 dc.DrawBitmap(bitmap_bg.bmp(), wxPoint((size.x - bitmap_bg.GetBmpSize().x) / 2, (size.y - bitmap_bg.GetBmpSize().y) / 2));
2514
2515 for (auto iter = m_group_info.rbegin(); iter != m_group_info.rend(); ++iter) {
2516 std::string tray_name = iter->first;
2517 wxColour tray_color = iter->second;
2518
2519 dc.SetPen(*wxTRANSPARENT_PEN);
2520
2521 if (tray_color == *wxWHITE) dc.SetPen(wxPen(wxColour("#EEEEEE"), 2));
2522 dc.SetBrush(wxBrush(tray_color));
2523
2524 int x = size.x / 2;
2525 int y = size.y / 2;
2526 int radius;
2527 if (wxGetApp().dark_mode())
2528 radius = size.x / 2 - int(size.x * 0.02);
2529 else
2530 radius = size.x / 2;
2531 endAngle += ev_angle;
2532
2533
2534 //draw body
2535 if (tray_color.Alpha() != 0) {
2536 dc.DrawEllipticArc(x - radius, y - radius, radius * 2, radius * 2, startAngle, endAngle);
2537 if (tray_color == *wxWHITE) dc.DrawEllipticArc(x - center_mask_radius, y - center_mask_radius, center_mask_radius * 2, center_mask_radius * 2, startAngle, endAngle);
2538 }
2539
2540 //draw selected
2541 if (!m_selected_index.empty() && m_selected_index == tray_name) {
2542 dc.SetPen(wxPen(0xCECECE, 2));
2543 dc.SetBrush(*wxTRANSPARENT_BRUSH);
2544 dc.DrawEllipticArc(x - radius, y - radius, radius * 2, radius * 2, startAngle, endAngle);
2545 dc.DrawEllipticArc(x - selected_radius, y - selected_radius,selected_radius * 2, selected_radius * 2, startAngle, endAngle);
2546 }
2547
2548 //...
2549 startAngle += ev_angle;
2550 }
2551
2552 //draw text
2553 startAngle = 0.0;
2554 endAngle = 0.0;
2555 for (auto iter = m_group_info.rbegin(); iter != m_group_info.rend(); ++iter) {
2556 std::string tray_name = iter->first;
2557 wxColour tray_color = iter->second;
2558
2559 int x = size.x / 2;
2560 int y = size.y / 2;
2561 float radius = size.x / 2 - 15.0;
2562 endAngle += ev_angle;
2563
2564 float midAngle = (startAngle + endAngle) / 2;
2565 float x_center = size.x / 2 + radius * cos(midAngle * M_PI / 180.0);
2566 float y_center = size.y / 2 + radius * sin(midAngle * M_PI / 180.0);
2567
2568 //draw tray
2569 dc.SetFont(::Label::Body_12);
2570 auto text_size = dc.GetTextExtent(tray_name);
2571 dc.SetTextForeground(tray_color.GetLuminance() < 0.6 ? *wxWHITE : wxColour("#262E30"));
2572 if (tray_color.Alpha() == 0) { dc.SetTextForeground(wxColour("#262E30")); }
2573
2574 dc.DrawText(tray_name, x_center - text_size.x / 2, size.y - y_center - text_size.y / 2);
2575
2576 //draw split line
2577 dc.SetPen(wxPen(*wxWHITE, 2));
2578 if (tray_color.Alpha() == 0) { dc.SetPen(wxPen(wxColour("#CECECE"), 2)); }
2579 dc.SetBrush(*wxTRANSPARENT_BRUSH);
2580 auto pos_sp_start = CalculateEndpoint(wxPoint(x, y), (360 - startAngle), size.x / 2 - FromDIP(3));
2581 dc.DrawLine(wxPoint(x, y), pos_sp_start);
2582
2583 //draw current
2584 //dc.DrawBitmap(backup_current_use_white.bmp(), x_center - text_size.x / 2 + FromDIP(3), size.y - y_center - text_size.y / 2 + FromDIP(11));
2585 //...
2586 startAngle += ev_angle;
2587 }
2588
2589 //draw center mask
2590 dc.SetPen(*wxTRANSPARENT_PEN);
2591 dc.SetBrush(wxBrush(*wxWHITE));
2592
2593 int x = size.x / 2;
2594 int y = size.y / 2;
2595 dc.DrawEllipticArc(x - center_mask_radius, y - center_mask_radius, center_mask_radius * 2, center_mask_radius * 2, 0, 360);
2596
2597 //draw center icon
2598 dc.DrawBitmap(bitmap_backup_tips_0.bmp(), wxPoint((size.x - bitmap_backup_tips_0.GetBmpSize().x) / 2, (size.y - bitmap_backup_tips_0.GetBmpSize().y) / 2));
2599 //dc.DrawBitmap(bitmap_backup_tips_1.bmp(), wxPoint((size.x - bitmap_backup_tips_1.GetBmpSize().x) / 2, (size.y - bitmap_backup_tips_1.GetBmpSize().y) / 2));
2600
2601 //draw material
2602 dc.SetTextForeground(wxColour("#323A3D"));
2603 dc.SetFont(Label::Head_15);
2604 auto text_size = dc.GetTextExtent(m_material_name);
2605 dc.DrawText(m_material_name, (size.x - text_size.x) / 2,(size.y - text_size.y) / 2 - FromDIP(12));
2606
2607 dc.SetFont(Label::Body_13);
2608 text_size = dc.GetTextExtent(m_group_index);
2609 dc.DrawText(m_group_index, (size.x - text_size.x) / 2, (size.y - text_size.y) / 2 + FromDIP(10));
2610}
static wxFont Body_13
Definition Label.hpp:54
static wxFont Head_15
Definition Label.hpp:44
static wxFont Body_12
Definition Label.hpp:55
std::string m_selected_index
Definition AmsMappingPopup.hpp:533
wxPoint CalculateEndpoint(const wxPoint &startPoint, int angle, int length)
Definition AmsMappingPopup.cpp:2495

References bitmap_backup_tips_0, bitmap_bg, Label::Body_12, Label::Body_13, CalculateEndpoint(), Label::Head_15, m_group_index, m_group_info, m_material_name, M_PI, and m_selected_index.

Referenced by render().

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

◆ GetAngle()

double Slic3r::GUI::AmsRMGroup::GetAngle ( wxPoint pointA,
wxPoint pointB )
2420{
2421 double deltaX = pointA.x - pointB.x;
2422 double deltaY = pointA.y - pointB.y;
2423 double angle = atan2(deltaY, deltaX);
2424
2425 angle = angle * 180.0 / M_PI;
2426
2427 if (angle < 0)
2428 angle += 360.0;
2429
2430 return angle;
2431}

References Slic3r::angle(), and M_PI.

Referenced by on_mouse_move().

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

◆ on_mouse_move()

void Slic3r::GUI::AmsRMGroup::on_mouse_move ( wxMouseEvent & evt)
2434{
2435 wxSize size = GetSize();
2436 auto mouseX = evt.GetPosition().x;
2437 auto mouseY = evt.GetPosition().y;
2438
2439 auto click_angle = 360.0 - GetAngle(wxPoint(mouseX,mouseY), wxPoint(size.x / 2, size.x / 2));
2440
2441
2442 float ev_angle = 360.0 / m_group_info.size();
2443 float startAngle = 0.0;
2444 float endAngle = 0.0;
2445
2446 for (auto iter = m_group_info.rbegin(); iter != m_group_info.rend(); ++iter) {
2447 std::string tray_name = iter->first;
2448 wxColour tray_color = iter->second;
2449
2450 int x = size.x / 2;
2451 int y = size.y / 2;
2452 int radius = size.x / 2;
2453 endAngle += ev_angle;
2454
2455 if (click_angle >= startAngle && click_angle < endAngle) {
2456 //to do
2457 set_index(tray_name);
2458 Refresh();
2459 return;
2460 }
2461
2462 startAngle += ev_angle;
2463 }
2464
2465 evt.Skip();
2466}
void set_index(std::string index)
Definition AmsMappingPopup.hpp:523
double GetAngle(wxPoint pointA, wxPoint pointB)
Definition AmsMappingPopup.cpp:2419

References GetAngle(), m_group_info, set_index(), and Slic3r::GUI::wxMouseEvent.

Referenced by AmsRMGroup().

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

◆ paintEvent()

void Slic3r::GUI::AmsRMGroup::paintEvent ( wxPaintEvent & evt)
2469{
2470 wxPaintDC dc(this);
2471 render(dc);
2472}
void render(wxDC &dc)
Definition AmsMappingPopup.cpp:2474

References render().

Referenced by AmsRMGroup().

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

◆ render()

void Slic3r::GUI::AmsRMGroup::render ( wxDC & dc)
2475{
2476#ifdef __WXMSW__
2477 wxSize size = GetSize();
2478 wxMemoryDC memdc;
2479 wxBitmap bmp(size.x, size.y);
2480 memdc.SelectObject(bmp);
2481 memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 });
2482
2483 {
2484 wxGCDC dc2(memdc);
2485 doRender(dc2);
2486 }
2487
2488 memdc.SelectObject(wxNullBitmap);
2489 dc.DrawBitmap(bmp, 0, 0);
2490#else
2491 doRender(dc);
2492#endif
2493}
void doRender(wxDC &dc)
Definition AmsMappingPopup.cpp:2502

References doRender().

Referenced by paintEvent().

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

◆ set_index()

void Slic3r::GUI::AmsRMGroup::set_index ( std::string index)
inline
523{m_selected_index = index;};

References m_selected_index.

Referenced by on_mouse_move().

Here is the caller graph for this function:

Member Data Documentation

◆ backup_current_use_black

ScalableBitmap Slic3r::GUI::AmsRMGroup::backup_current_use_black
private

Referenced by AmsRMGroup().

◆ backup_current_use_white

ScalableBitmap Slic3r::GUI::AmsRMGroup::backup_current_use_white
private

Referenced by AmsRMGroup().

◆ bitmap_backup_tips_0

ScalableBitmap Slic3r::GUI::AmsRMGroup::bitmap_backup_tips_0
private

Referenced by AmsRMGroup(), and doRender().

◆ bitmap_backup_tips_1

ScalableBitmap Slic3r::GUI::AmsRMGroup::bitmap_backup_tips_1
private

◆ bitmap_bg

ScalableBitmap Slic3r::GUI::AmsRMGroup::bitmap_bg
private

Referenced by AmsRMGroup(), and doRender().

◆ bitmap_editable

ScalableBitmap Slic3r::GUI::AmsRMGroup::bitmap_editable
private

Referenced by AmsRMGroup().

◆ bitmap_editable_light

ScalableBitmap Slic3r::GUI::AmsRMGroup::bitmap_editable_light
private

Referenced by AmsRMGroup().

◆ m_group_index

wxString Slic3r::GUI::AmsRMGroup::m_group_index
private

Referenced by AmsRMGroup(), and doRender().

◆ m_group_info

std::map<std::string, wxColour> Slic3r::GUI::AmsRMGroup::m_group_info
private

Referenced by AmsRMGroup(), doRender(), and on_mouse_move().

◆ m_material_name

wxString Slic3r::GUI::AmsRMGroup::m_material_name
private

Referenced by AmsRMGroup(), and doRender().

◆ m_selected_index

std::string Slic3r::GUI::AmsRMGroup::m_selected_index
private

Referenced by doRender(), and set_index().


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