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

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

Inheritance diagram for Slic3r::GUI::AuFile:
Collaboration diagram for Slic3r::GUI::AuFile:

Public Member Functions

 AuFile (wxWindow *parent, boost::filesystem::path file_path, wxString file_name, AuxiliaryFolderType type, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
void enter_rename_mode ()
void exit_rename_mode ()
void OnPaint (wxPaintEvent &evt)
void PaintBackground (wxDC &dc)
void OnEraseBackground (wxEraseEvent &evt)
void PaintForeground (wxDC &dc)
void on_mouse_enter (wxMouseEvent &evt)
void on_mouse_leave (wxMouseEvent &evt)
void on_input_enter (wxCommandEvent &evt)
void on_dclick (wxMouseEvent &evt)
void on_mouse_left_up (wxMouseEvent &evt)
void on_set_cover ()
void on_set_delete ()
void on_set_rename ()
void on_set_open ()
void set_cover (bool cover)
void msw_rescale ()
 ~AuFile ()

Public Attributes

AuxiliaryFolderType m_type
bool m_hover {false}
bool m_cover {false}
wxStaticText * m_text_name {nullptr}
::TextInput * m_input_name {nullptr}
boost::filesystem::path m_file_path
wxString m_add_file
wxString m_file_name
wxString cover_text_left
wxString cover_text_right
wxString cover_text_cover
ScalableBitmap m_file_bitmap
ScalableBitmap m_file_cover
ScalableBitmap m_file_edit_mask
ScalableBitmap m_file_delete
wxStaticBitmap * m_file_exit_rename
ScalableBitmap m_bitmap_excel
ScalableBitmap m_bitmap_pdf
ScalableBitmap m_bitmap_txt

Detailed Description

Constructor & Destructor Documentation

◆ AuFile()

Slic3r::GUI::AuFile::AuFile ( wxWindow * parent,
boost::filesystem::path file_path,
wxString file_name,
AuxiliaryFolderType type,
wxWindowID id = wxID_ANY,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = wxTAB_TRAVERSAL )
105{
106 m_type = type;
107 m_file_path = file_path;
108 m_file_name = file_name;
109
111 wxPanel::Create(parent, id, pos, panel_size, style);
112 SetBackgroundColour(StateColor::darkModeColorFor(AUFILE_GREY300));
113 wxBoxSizer *sizer_body = new wxBoxSizer(wxVERTICAL);
114
115 SetSize(panel_size);
116
117 if (m_type == MODEL_PICTURE) {
118 if (m_file_path.empty()) { return; }
119 auto image = new wxImage(encode_path(m_file_path.string().c_str()));
120
121 //constrain
122 auto size = wxSize(0, 0);
123 float proportion = float(image->GetSize().x) / float(image->GetSize().y);
124 if (proportion >= 1) {
125 size.x = AUFILE_PICTURES_SIZE.x;
126 size.y = AUFILE_PICTURES_SIZE.x / proportion;
127 } else {
128 size.y = AUFILE_PICTURES_SIZE.y;
129 size.x = AUFILE_PICTURES_SIZE.y * proportion;
130 }
131
132 image->Rescale(size.x, size.y);
133 m_file_bitmap.bmp() = wxBitmap(*image);
134 } else {
135 m_bitmap_excel = ScalableBitmap(this, "placeholder_excel", 168);
136 m_bitmap_pdf = ScalableBitmap(this, "placeholder_pdf", 168);
137 m_bitmap_txt = ScalableBitmap(this, "placeholder_txt", 168);
138
140 if (m_type == BILL_OF_MATERIALS) {
141 if (m_file_path.extension() == ".xls" || m_file_path.extension() == ".xlsx") {
143 }
144
145 if (m_file_path.extension() == ".pdf") { m_file_bitmap = m_bitmap_pdf; }
146
147 }
149 }
150
151 m_add_file = _L("Add File");
152 cover_text_left = _L("Set as cover");
153 cover_text_right = _L("Rename");
154 cover_text_cover = _L("Cover");
155
156 m_file_cover = ScalableBitmap(this, "auxiliary_cover", 40);
157 m_file_edit_mask = ScalableBitmap(this, "auxiliary_edit_mask", 30);
158 m_file_delete = ScalableBitmap(this, "auxiliary_delete", 20);
159
160
161 auto m_text_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(panel_size.x, AUFILE_TEXT_HEIGHT), wxTAB_TRAVERSAL);
162 m_text_panel->SetBackgroundColour(StateColor::darkModeColorFor(AUFILE_GREY300));
163
164
165 wxBoxSizer *m_text_sizer = new wxBoxSizer(wxHORIZONTAL);
166 m_text_name = new wxStaticText(m_text_panel, wxID_ANY, m_file_name, wxDefaultPosition, wxSize(panel_size.x, -1), wxST_ELLIPSIZE_END);
167 m_text_name->Wrap(panel_size.x - FromDIP(10));
169 m_text_name->SetForegroundColour(StateColor::darkModeColorFor(*wxBLACK));
170
171 m_input_name = new ::TextInput(m_text_panel, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxSize(panel_size.x - FromDIP(28), FromDIP(32)), wxTE_PROCESS_ENTER);
172 m_input_name->GetTextCtrl()->SetFont(::Label::Body_13);
174 m_input_name->Hide();
175
176 m_file_exit_rename = new wxStaticBitmap(m_text_panel, wxID_ANY, create_scaled_bitmap("auxiliary_delete", this, 20), wxDefaultPosition, wxSize(FromDIP(20), FromDIP(20)), 0);
177
178 m_file_exit_rename->Bind(wxEVT_LEFT_UP, [this](auto& e) {
180 });
181
182 m_text_sizer->Add(0, 0, 1, wxEXPAND, 0);
183 m_text_sizer->Add(m_text_name, 0, wxALIGN_CENTER, 0);
184 m_text_sizer->Add(m_input_name, 0, wxALIGN_CENTER, 0);
185 m_text_sizer->Add( 0, 0, 1, wxEXPAND, 0 );
186 m_text_sizer->Add(m_file_exit_rename, 0, wxALIGN_CENTER, 0);
187 m_file_exit_rename->Hide();
188
189 m_text_panel->SetSizer(m_text_sizer);
190 m_text_panel->Layout();
191 sizer_body->Add(0, 0, 0, wxTOP, panel_size.y - AUFILE_TEXT_HEIGHT);
192 sizer_body->Add(m_text_panel, 0, wxALIGN_CENTER, 0);
193
194 SetSizer(sizer_body);
195 Layout();
196 Fit();
197
198 Bind(wxEVT_PAINT, &AuFile::OnPaint, this);
199 Bind(wxEVT_ERASE_BACKGROUND, &AuFile::OnEraseBackground, this);
200 Bind(wxEVT_ENTER_WINDOW, &AuFile::on_mouse_enter, this);
201 Bind(wxEVT_LEAVE_WINDOW, &AuFile::on_mouse_leave, this);
202 Bind(wxEVT_LEFT_UP, &AuFile::on_mouse_left_up, this);
203 Bind(wxEVT_LEFT_DCLICK, &AuFile::on_dclick, this);
204 m_input_name->Bind(wxEVT_TEXT_ENTER, &AuFile::on_input_enter, this);
205}
#define AUFILE_PICTURES_SIZE
Definition Auxiliary.hpp:67
#define AUFILE_PANEL_SIZE
Definition Auxiliary.hpp:70
@ BILL_OF_MATERIALS
Definition Auxiliary.hpp:76
@ OTHERS
Definition Auxiliary.hpp:78
@ MODEL_PICTURE
Definition Auxiliary.hpp:75
@ ASSEMBLY_GUIDE
Definition Auxiliary.hpp:77
#define AUFILE_GREY300
Definition Auxiliary.hpp:61
#define AUFILE_TEXT_HEIGHT
Definition Auxiliary.hpp:71
#define AUFILE_PICTURES_PANEL_SIZE
Definition Auxiliary.hpp:68
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
#define style
Definition WipeTowerDialog.cpp:101
static wxFont Body_13
Definition Label.hpp:54
static wxFont Body_14
Definition Label.hpp:53
ScalableBitmap m_file_bitmap
Definition Auxiliary.hpp:105
void on_mouse_enter(wxMouseEvent &evt)
Definition Auxiliary.cpp:375
ScalableBitmap m_file_cover
Definition Auxiliary.hpp:106
wxString cover_text_right
Definition Auxiliary.hpp:103
ScalableBitmap m_bitmap_pdf
Definition Auxiliary.hpp:112
wxString m_add_file
Definition Auxiliary.hpp:100
void on_input_enter(wxCommandEvent &evt)
Definition Auxiliary.cpp:387
ScalableBitmap m_file_edit_mask
Definition Auxiliary.hpp:107
ScalableBitmap m_bitmap_txt
Definition Auxiliary.hpp:113
void on_mouse_left_up(wxMouseEvent &evt)
Definition Auxiliary.cpp:477
::TextInput * m_input_name
Definition Auxiliary.hpp:98
void OnEraseBackground(wxEraseEvent &evt)
Definition Auxiliary.cpp:292
wxStaticBitmap * m_file_exit_rename
Definition Auxiliary.hpp:109
boost::filesystem::path m_file_path
Definition Auxiliary.hpp:99
wxString cover_text_cover
Definition Auxiliary.hpp:104
wxString m_file_name
Definition Auxiliary.hpp:101
void on_mouse_leave(wxMouseEvent &evt)
Definition Auxiliary.cpp:381
AuxiliaryFolderType m_type
Definition Auxiliary.hpp:94
ScalableBitmap m_file_delete
Definition Auxiliary.hpp:108
void OnPaint(wxPaintEvent &evt)
Definition Auxiliary.cpp:225
wxStaticText * m_text_name
Definition Auxiliary.hpp:97
ScalableBitmap m_bitmap_excel
Definition Auxiliary.hpp:111
void exit_rename_mode()
Definition Auxiliary.cpp:217
void on_dclick(wxMouseEvent &evt)
Definition Auxiliary.cpp:469
wxString cover_text_left
Definition Auxiliary.hpp:102
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
std::string encode_path(const char *src)
Definition utils.cpp:1382
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 _L, ASSEMBLY_GUIDE, AUFILE_GREY300, AUFILE_PANEL_SIZE, AUFILE_PICTURES_PANEL_SIZE, AUFILE_PICTURES_SIZE, AUFILE_TEXT_HEIGHT, BILL_OF_MATERIALS, Label::Body_13, Label::Body_14, cover_text_cover, cover_text_left, cover_text_right, create_scaled_bitmap(), StateColor::darkModeColorFor(), Slic3r::encode_path(), exit_rename_mode(), m_add_file, m_bitmap_excel, m_bitmap_pdf, m_bitmap_txt, m_file_bitmap, m_file_cover, m_file_delete, m_file_edit_mask, m_file_exit_rename, m_file_name, m_file_path, m_input_name, m_text_name, m_type, MODEL_PICTURE, on_dclick(), on_input_enter(), on_mouse_enter(), on_mouse_leave(), on_mouse_left_up(), OnEraseBackground(), OnPaint(), OTHERS, style, and wxStaticText.

Here is the call graph for this function:

◆ ~AuFile()

Slic3r::GUI::AuFile::~AuFile ( )
608{}

Member Function Documentation

◆ enter_rename_mode()

void Slic3r::GUI::AuFile::enter_rename_mode ( )
208{
209 m_input_name->Show();
210 m_file_exit_rename->Show();
211 m_text_name->Hide();
212 auto name = m_file_name.SubString(0, (m_file_name.Find(".") - 1));
213 m_input_name->GetTextCtrl()->ChangeValue(name);
214 Layout();
215}

References m_file_exit_rename, m_file_name, m_input_name, and m_text_name.

Referenced by on_set_rename().

Here is the caller graph for this function:

◆ exit_rename_mode()

void Slic3r::GUI::AuFile::exit_rename_mode ( )
218{
219 m_input_name->Hide();
220 m_file_exit_rename->Hide();
221 m_text_name->Show();
222 Layout();
223}

References m_file_exit_rename, m_input_name, and m_text_name.

Referenced by AuFile(), on_input_enter(), and on_mouse_left_up().

Here is the caller graph for this function:

◆ msw_rescale()

void Slic3r::GUI::AuFile::msw_rescale ( )
611{
612 m_file_cover = ScalableBitmap(this, "auxiliary_cover", 40);
613 m_file_edit_mask = ScalableBitmap(this, "auxiliary_edit_mask", FromDIP(30));
614 m_file_delete = ScalableBitmap(this, "auxiliary_delete", 20);
615
616 if (m_type == MODEL_PICTURE) {
617 if (m_file_path.empty()) { return;}
618 auto image = new wxImage(encode_path(m_file_path.string().c_str()));
619 // constrain
620 auto size = wxSize(0, 0);
621 float proportion = float(image->GetSize().x) / float(image->GetSize().y);
622 if (proportion >= 1) {
623 size.x = FromDIP(300);
624 size.y = FromDIP(300) / proportion;
625 } else {
626 size.y = FromDIP(300);
627 size.x = FromDIP(300) * proportion;
628 }
629
630 image->Rescale(size.x, size.y);
631 m_file_bitmap.bmp() = wxBitmap(*image);
632 } else {
633 m_bitmap_excel = ScalableBitmap(this, "placeholder_excel", 168);
634 m_bitmap_pdf = ScalableBitmap(this, "placeholder_pdf", 168);
635 m_bitmap_txt = ScalableBitmap(this, "placeholder_txt", 168);
636
640 }
641 Refresh();
642}

References ASSEMBLY_GUIDE, BILL_OF_MATERIALS, Slic3r::encode_path(), m_bitmap_excel, m_bitmap_pdf, m_bitmap_txt, m_file_bitmap, m_file_cover, m_file_delete, m_file_edit_mask, m_file_path, m_type, MODEL_PICTURE, and OTHERS.

Referenced by Slic3r::GUI::AuFolderPanel::msw_rescale().

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

◆ on_dclick()

void Slic3r::GUI::AuFile::on_dclick ( wxMouseEvent & evt)
470{
471 if (m_type == AddFileButton)
472 return;
473 else
475}
@ AddFileButton
Definition Auxiliary.hpp:81
bool desktop_open_project_attachment(wxWindow *parent, const boost::filesystem::path &path)
Definition GUI.cpp:678

References AddFileButton, Slic3r::GUI::desktop_open_project_attachment(), m_file_path, m_type, and Slic3r::GUI::wxMouseEvent.

Referenced by AuFile().

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

◆ on_input_enter()

void Slic3r::GUI::AuFile::on_input_enter ( wxCommandEvent & evt)
388{
389 auto new_file_name = m_input_name->GetTextCtrl()->GetValue();
390 auto m_valid_type = Valid;
391 wxString info_line;
392
393 const char *unusable_symbols = "<>[]:/\\|?*\"";
394
395 const std::string unusable_suffix = PresetCollection::get_suffix_modified(); //"(modified)";
396 for (size_t i = 0; i < std::strlen(unusable_symbols); i++) {
397 if (new_file_name.find_first_of(unusable_symbols[i]) != std::string::npos) {
398 info_line = _L("Name is invalid;") + "\n" + _L("illegal characters:") + " " + unusable_symbols;
399 m_valid_type = NoValid;
400 break;
401 }
402 }
403
404 if (m_valid_type == Valid && new_file_name.find(unusable_suffix) != std::string::npos) {
405 info_line = _L("Name is invalid;") + "\n" + _L("illegal suffix:") + "\n\t" + from_u8(PresetCollection::get_suffix_modified());
406 m_valid_type = NoValid;
407 }
408
409 auto existing = false;
410 auto dir = m_file_path.parent_path();
411 auto new_fullname = new_file_name + m_file_path.extension().string();
412
413
414 wxString new_fullname_path = wxString(dir.wstring()) + "/" + new_fullname;
415 fs::path new_dir_path(new_fullname_path.ToStdWstring());
416
417
418 if (fs::exists(new_dir_path)) existing = true;
419
420 if (m_valid_type == Valid && existing) {
421 info_line = from_u8((boost::format(_u8L("The name \"%1%\" already exists.")) % new_file_name).str());
422 m_valid_type = NoValid;
423 }
424
425 if (m_valid_type == Valid && new_file_name.empty()) {
426 info_line = _L("The name field is not allowed to be empty.");
427 m_valid_type = NoValid;
428 }
429
430 if (m_valid_type == Valid && new_file_name.find_first_of(' ') == 0) {
431 info_line = _L("The name is not allowed to start with a space.");
432 m_valid_type = NoValid;
433 }
434
435 if (m_valid_type == Valid && new_file_name.find_last_of(' ') == new_file_name.length() - 1) {
436 info_line = _L("The name is not allowed to end with a space.");
437 m_valid_type = NoValid;
438 }
439
440 if (m_valid_type == Valid) {
441 fs::path oldPath = m_file_path;
442 fs::path newPath(new_dir_path);
443 fs::rename(oldPath, newPath);
444 } else {
445 /*MessageDialog msg_wingow(nullptr, info_line, "",
446 wxICON_WARNING | wxOK);
447 if (msg_wingow.ShowModal() == wxID_CANCEL) {
448 m_input_name->GetTextCtrl()->SetValue(wxEmptyString);
449 return;
450 }*/
451
452 return;
453 }
454
455 // post event
456 auto event = wxCommandEvent(EVT_AUXILIARY_UPDATE_RENAME);
457 event.SetString(wxString::Format("%s|%s|%s", s_default_folders[m_type], m_file_path.wstring(), new_dir_path.wstring()));
458 event.SetEventObject(m_parent);
459 wxPostEvent(m_parent, event);
460
461 // update layout
462 m_file_path = new_dir_path.string();
463 m_file_name = new_fullname;
464 m_text_name->SetLabel(new_fullname);
466 // evt.Skip();
467}
static const std::array< wxString, 5 > s_default_folders
Definition Auxiliary.hpp:84
@ NoValid
Definition Auxiliary.hpp:87
@ Valid
Definition Auxiliary.hpp:87
static const std::string & get_suffix_modified()
Definition Preset.cpp:3766
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
#define _u8L(s)
Definition I18N.hpp:11

References _L, _u8L, exit_rename_mode(), Slic3r::GUI::from_u8(), Slic3r::PresetCollection::get_suffix_modified(), m_file_name, m_file_path, m_input_name, m_text_name, m_type, NoValid, s_default_folders, and Valid.

Referenced by AuFile().

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

◆ on_mouse_enter()

void Slic3r::GUI::AuFile::on_mouse_enter ( wxMouseEvent & evt)
376{
377 m_hover = true;
378 Refresh();
379}
bool m_hover
Definition Auxiliary.hpp:95

References m_hover, and Slic3r::GUI::wxMouseEvent.

Referenced by AuFile().

Here is the caller graph for this function:

◆ on_mouse_leave()

void Slic3r::GUI::AuFile::on_mouse_leave ( wxMouseEvent & evt)
382{
383 m_hover = false;
384 Refresh();
385}

References m_hover, and Slic3r::GUI::wxMouseEvent.

Referenced by AuFile().

Here is the caller graph for this function:

◆ on_mouse_left_up()

void Slic3r::GUI::AuFile::on_mouse_left_up ( wxMouseEvent & evt)
478{
479 if (m_type == AddFileButton) {
480 return;
481 }
482
484
485 auto pos = evt.GetPosition();
486 // set cover
487 auto mask_size = wxSize(GetSize().x, m_file_edit_mask.GetBmpSize().y);
488 auto cover_left = 0;
489 auto cover_top = size.y - mask_size.y;
490 auto cover_right = mask_size.x / 2;
491 auto cover_bottom = size.y;
492
493 if (pos.x > cover_left && pos.x < cover_right && pos.y > cover_top && pos.y < cover_bottom) {
494 if(m_type == MODEL_PICTURE)
495 on_set_cover();
496 /* else
497 on_set_rename();*/
498 return;
499 }
500
501 // rename
502 auto rename_left = mask_size.x / 2;
503 auto rename_top = size.y - mask_size.y;
504 auto rename_right = mask_size.x;
505 auto rename_bottom = size.y;
506 if (pos.x > rename_left && pos.x < rename_right && pos.y > rename_top && pos.y < rename_bottom) { on_set_rename(); return; }
507
508 // close
509 auto close_left = size.x - m_file_delete.GetBmpSize().x - FromDIP(10);
510 auto close_top = FromDIP(10);
511 auto close_right = size.x - FromDIP(10);
512 auto close_bottom = m_file_delete.GetBmpSize().y + FromDIP(10);
513 if (pos.x > close_left && pos.x < close_right && pos.y > close_top && pos.y < close_bottom) { on_set_delete(); return; }
514
516}
#define AUFILE_SIZE
Definition Auxiliary.hpp:69
void on_set_cover()
Definition Auxiliary.cpp:518
void on_set_rename()
Definition Auxiliary.cpp:598
void on_set_delete()
Definition Auxiliary.cpp:563
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References AddFileButton, AUFILE_PICTURES_SIZE, AUFILE_SIZE, exit_rename_mode(), m_file_delete, m_file_edit_mask, m_type, MODEL_PICTURE, on_set_cover(), on_set_delete(), on_set_rename(), and Slic3r::GUI::wxMouseEvent.

Referenced by AuFile().

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

◆ on_set_cover()

void Slic3r::GUI::AuFile::on_set_cover ( )
519{
520 fs::path path(into_path(m_file_name));
521 ensure_model_info()->cover_file = path.string();
522 //wxGetApp().plater()->model().model_info->cover_file = m_file_name.ToStdString();
523
524 auto full_path = m_file_path.parent_path();
525 auto full_root_path = full_path.parent_path();
526 auto full_root_path_str = encode_path(full_root_path.string().c_str());
527 auto dir = wxString::Format("%s/.thumbnails", full_root_path_str);
528
529 fs::path dir_path(dir.ToStdWstring());
530
531 if (!fs::exists(dir_path)) {
532 fs::create_directory(dir_path);
533 }
534
535 bool result = true;
536 wxImage thumbnail_img;
537
538 result = generate_image(m_file_path.string(), thumbnail_img, _3MF_COVER_SIZE);
539 if (result) {
540 auto cover_img_path = dir_path.string() + "/thumbnail_3mf.png";
541 thumbnail_img.SaveFile(encode_path(cover_img_path.c_str()));
542 }
543
544 result = generate_image(m_file_path.string(), thumbnail_img, PRINTER_THUMBNAIL_SMALL_SIZE);
545 if (result) {
546 auto small_img_path = dir_path.string() + "/thumbnail_small.png";
547 thumbnail_img.SaveFile(encode_path(small_img_path.c_str()));
548 }
549
550 result = generate_image(m_file_path.string(), thumbnail_img, PRINTER_THUMBNAIL_MIDDLE_SIZE);
551 if (result) {
552 auto middle_img_path = dir_path.string() + "/thumbnail_middle.png";
553 thumbnail_img.SaveFile(encode_path(middle_img_path.c_str()));
554 }
555
556 wxGetApp().plater()->set_plater_dirty(true);
557 auto evt = wxCommandEvent(EVT_AUXILIARY_UPDATE_COVER);
558 evt.SetString(s_default_folders[m_type]);
559 evt.SetEventObject(m_parent);
560 wxPostEvent(m_parent, evt);
561}
#define PRINTER_THUMBNAIL_SMALL_SIZE
Definition GUI_Utils.hpp:483
#define _3MF_COVER_SIZE
Definition GUI_Utils.hpp:482
#define PRINTER_THUMBNAIL_MIDDLE_SIZE
Definition GUI_Utils.hpp:484
static std::shared_ptr< ModelInfo > ensure_model_info()
Definition Auxiliary.cpp:95
boost::filesystem::path into_path(const wxString &str)
Definition GUI.cpp:564
bool generate_image(const std::string &filename, wxImage &image, wxSize img_size, int method)
Definition GUI_Utils.cpp:508

References _3MF_COVER_SIZE, Slic3r::encode_path(), Slic3r::GUI::ensure_model_info(), Slic3r::GUI::generate_image(), Slic3r::GUI::into_path(), m_file_name, m_file_path, m_type, PRINTER_THUMBNAIL_MIDDLE_SIZE, PRINTER_THUMBNAIL_SMALL_SIZE, and s_default_folders.

Referenced by on_mouse_left_up().

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

◆ on_set_delete()

void Slic3r::GUI::AuFile::on_set_delete ( )
564{
565 fs::path bfs_path = m_file_path;
566 auto is_fine = fs::remove(bfs_path);
567
568 if (m_cover) {
569 auto full_path = m_file_path.parent_path();
570 auto full_root_path = full_path.parent_path();
571 auto full_root_path_str = encode_path(full_root_path.string().c_str());
572 auto dir = wxString::Format("%s/.thumbnails", full_root_path_str);
573 fs::path dir_path(dir.ToStdWstring());
574
575 auto cover_img_path = dir_path.string() + "/thumbnail_3mf.png";
576 auto small_img_path = dir_path.string() + "/thumbnail_small.png";
577 auto middle_img_path = dir_path.string() + "/thumbnail_middle.png";
578
579 if (fs::exists(fs::path(cover_img_path))) { fs::remove(fs::path(cover_img_path));}
580 if (fs::exists(fs::path(small_img_path))) { fs::remove(fs::path(small_img_path)); }
581 if (fs::exists(fs::path(middle_img_path))) { fs::remove(fs::path(middle_img_path)); }
582 }
583
584 if (wxGetApp().plater()->model().model_info != nullptr) {
585 if (wxGetApp().plater()->model().model_info->cover_file == m_file_name) {
586 wxGetApp().plater()->model().model_info->cover_file = "";
587 }
588 }
589
590 if (is_fine) {
591 auto evt = wxCommandEvent(EVT_AUXILIARY_UPDATE_DELETE);
592 evt.SetString(wxString::Format("%s|%s", s_default_folders[m_type], m_file_path.wstring()));
593 evt.SetEventObject(m_parent);
594 wxPostEvent(m_parent, evt);
595 }
596}
bool m_cover
Definition Auxiliary.hpp:96
static Plater * plater()
Definition GUI_Factories.cpp:400

References Slic3r::encode_path(), m_cover, m_file_name, m_file_path, m_type, Slic3r::GUI::plater(), and s_default_folders.

Referenced by on_mouse_left_up().

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

◆ on_set_open()

void Slic3r::GUI::AuFile::on_set_open ( )
600{}

◆ on_set_rename()

void Slic3r::GUI::AuFile::on_set_rename ( )
void enter_rename_mode()
Definition Auxiliary.cpp:207

References enter_rename_mode().

Referenced by on_mouse_left_up().

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

◆ OnEraseBackground()

void Slic3r::GUI::AuFile::OnEraseBackground ( wxEraseEvent & evt)
292{}

Referenced by AuFile().

Here is the caller graph for this function:

◆ OnPaint()

void Slic3r::GUI::AuFile::OnPaint ( wxPaintEvent & evt)
226{
227 wxPaintDC dc(this);
228#ifdef __WXMSW__
229 wxSize size = GetSize();
230 wxMemoryDC memdc;
231 wxBitmap bmp(size.x, size.y);
232 memdc.SelectObject(bmp);
233 memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 });
234
235 {
236 wxGCDC dc2(memdc);
237 PaintBackground(dc2);
238 PaintForeground(dc2);
239 }
240
241 memdc.SelectObject(wxNullBitmap);
242 dc.DrawBitmap(bmp, 0, 0);
243#else
244 PaintBackground(dc);
245 PaintForeground(dc);
246#endif
247}
void PaintBackground(wxDC &dc)
Definition Auxiliary.cpp:249
void PaintForeground(wxDC &dc)
Definition Auxiliary.cpp:294

References PaintBackground(), and PaintForeground().

Referenced by AuFile().

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

◆ PaintBackground()

void Slic3r::GUI::AuFile::PaintBackground ( wxDC & dc)
250{
251 wxColour backgroundColour = GetBackgroundColour();
252 if (!backgroundColour.Ok()) backgroundColour = AUFILE_GREY300;
253 dc.SetBrush(wxBrush(backgroundColour));
254 dc.SetPen(wxPen(backgroundColour, 1));
255 wxRect windowRect(wxPoint(0, 0), GetClientSize());
256
257 //CalcUnscrolledPosition(windowRect.x, windowRect.y, &windowRect.x, &windowRect.y);
258 dc.DrawRectangle(windowRect);
259
260
262
263 if (m_type == AddFileButton)
264 {
265 auto pen_width = FromDIP(2);
266 dc.SetPen(wxPen(AUFILE_GREY500, pen_width));
268 dc.DrawRoundedRectangle(pen_width / 2, pen_width / 2, size.x - pen_width / 2, size.y - pen_width / 2, AUFILE_ROUNDING);
269
270 auto line_length = FromDIP(50);
271 dc.DrawLine(wxPoint((size.x - line_length) / 2, size.y / 2), wxPoint((size.x + line_length) / 2, size.y / 2));
272 dc.DrawLine(wxPoint(size.x / 2, (size.y - line_length) / 2), wxPoint(size.x / 2, (size.y + line_length) / 2));
273
274 dc.SetFont(Label::Body_16);
275 auto sizet = dc.GetTextExtent(m_add_file);
276 auto pos = wxPoint(0, 0);
277 pos.x = (size.x - sizet.x) / 2;
278 pos.y = (size.y - 40); // to modify
279 dc.SetTextForeground(AUFILE_GREY500);
280 dc.DrawText(m_add_file, pos);
281 }
282 else {
283 // ORCA match look with add button
284 auto pen_width = FromDIP(2);
285 dc.SetPen(wxPen(AUFILE_GREY500, pen_width));
287 dc.DrawRoundedRectangle(pen_width / 2, pen_width / 2, size.x - pen_width / 2, size.y - pen_width / 2, AUFILE_ROUNDING);
288 dc.DrawBitmap(m_file_bitmap.bmp(), (size.x - m_file_bitmap.GetBmpWidth()) / 2, (size.y - m_file_bitmap.GetBmpHeight()) / 2);
289 }
290}
#define AUFILE_GREY500
Definition Auxiliary.hpp:60
#define AUFILE_GREY200
Definition Auxiliary.hpp:62
#define AUFILE_ROUNDING
Definition Auxiliary.hpp:72
static wxFont Body_16
Definition Label.hpp:51

References AddFileButton, AUFILE_GREY200, AUFILE_GREY300, AUFILE_GREY500, AUFILE_PICTURES_SIZE, AUFILE_ROUNDING, AUFILE_SIZE, Label::Body_16, StateColor::darkModeColorFor(), m_add_file, m_file_bitmap, m_type, and MODEL_PICTURE.

Referenced by OnPaint().

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

◆ PaintForeground()

void Slic3r::GUI::AuFile::PaintForeground ( wxDC & dc)
295{
297
298 if (m_hover) {
299
300 // ORCA add hover effect to borders
302 auto pen_width = FromDIP(2);
303 dc.SetPen(wxPen(AUFILE_BRAND, pen_width));
304 dc.SetBrush(*wxTRANSPARENT_BRUSH);
305 dc.DrawRoundedRectangle(pen_width / 2, pen_width / 2, size.x - pen_width / 2, size.y - pen_width / 2, AUFILE_ROUNDING);
306 }
307
308 if (m_type == AddFileButton) {
309 auto line_length = FromDIP(50);
310 dc.DrawLine(wxPoint((size.x - line_length) / 2, size.y / 2), wxPoint((size.x + line_length) / 2, size.y / 2));
311 dc.DrawLine(wxPoint(size.x / 2, (size.y - line_length) / 2), wxPoint(size.x / 2, (size.y + line_length) / 2));
312
313 auto sizet = dc.GetTextExtent(m_add_file);
314 auto pos = wxPoint(0, 0);
315 pos.x = (size.x - sizet.x) / 2;
316 pos.y = (size.y - 40); // to modify
317 dc.SetTextForeground(AUFILE_BRAND);
318 dc.DrawText(m_add_file, pos);
319 return;
320 }
321
322 if (m_type == MODEL_PICTURE) {
323 dc.DrawBitmap(m_file_edit_mask.bmp(), 0, size.y - m_file_edit_mask.GetBmpSize().y);
324 }
325
326
327 dc.SetFont(Label::Body_12);
328 dc.SetTextForeground(*wxWHITE);
329 if (m_type == MODEL_PICTURE) {
330 // left text
331 auto sizet = dc.GetTextExtent(cover_text_left);
332 auto pos = wxPoint(0, 0);
333 pos.x = (size.x / 2 - sizet.x) / 2;
334 pos.y = (size.y - (m_file_edit_mask.GetBmpSize().y + sizet.y) / 2);
335 dc.DrawText(cover_text_left, pos);
336
337 // right text
338 sizet = dc.GetTextExtent(cover_text_right);
339 pos = wxPoint(0, 0);
340 pos.x = size.x / 2 + (size.x / 2 - sizet.x) / 2;
341 pos.y = (size.y - (m_file_edit_mask.GetBmpSize().y + sizet.y) / 2);
342 dc.DrawText(cover_text_right, pos);
343
344 // Split
345 dc.SetPen(*wxWHITE);
346 dc.SetBrush(*wxWHITE);
347 pos = wxPoint(0, 0);
348 pos.x = size.x / 2 - 1;
349 pos.y = size.y - FromDIP(24) - (m_file_edit_mask.GetBmpSize().y - FromDIP(24)) / 2;
350 dc.DrawRectangle(pos.x, pos.y, 2, FromDIP(24));
351 } else {
352 // right text
353 /* auto sizet = dc.GetTextExtent(cover_text_right);
354 auto pos = wxPoint(0, 0);
355 pos.x = (size.x - sizet.x) / 2;
356 pos.y = (size.y - (m_file_edit_mask.GetBmpSize().y + sizet.y) / 2);
357 dc.DrawText(cover_text_right, pos);*/
358 }
359 }
360
361 if (m_cover) {
362 dc.SetTextForeground(*wxWHITE);
363 dc.DrawBitmap(m_file_cover.bmp(), size.x - m_file_cover.GetBmpSize().x, 0);
364 dc.SetFont(Label::Body_12);
365 auto sizet = dc.GetTextExtent(cover_text_cover);
366 auto pos = wxPoint(0, 0);
367 pos.x = size.x - sizet.x - FromDIP(3);
368 pos.y = FromDIP(3);
369 dc.DrawText(cover_text_cover, pos);
370 }
371
372 if (m_hover) { dc.DrawBitmap(m_file_delete.bmp(), size.x - m_file_delete.GetBmpSize().x - FromDIP(10), FromDIP(10)); }
373}
#define AUFILE_BRAND
Definition Auxiliary.hpp:63
static wxFont Body_12
Definition Label.hpp:55

References AddFileButton, ASSEMBLY_GUIDE, AUFILE_BRAND, AUFILE_PICTURES_SIZE, AUFILE_ROUNDING, AUFILE_SIZE, BILL_OF_MATERIALS, Label::Body_12, cover_text_cover, cover_text_left, cover_text_right, m_add_file, m_cover, m_file_cover, m_file_delete, m_file_edit_mask, m_hover, m_type, MODEL_PICTURE, and OTHERS.

Referenced by OnPaint().

Here is the caller graph for this function:

◆ set_cover()

void Slic3r::GUI::AuFile::set_cover ( bool cover)
603{
604 m_cover = cover;
605 Refresh();
606}

References m_cover.

Referenced by Slic3r::GUI::AuFolderPanel::update_cover().

Here is the caller graph for this function:

Member Data Documentation

◆ cover_text_cover

wxString Slic3r::GUI::AuFile::cover_text_cover

Referenced by AuFile(), and PaintForeground().

◆ cover_text_left

wxString Slic3r::GUI::AuFile::cover_text_left

Referenced by AuFile(), and PaintForeground().

◆ cover_text_right

wxString Slic3r::GUI::AuFile::cover_text_right

Referenced by AuFile(), and PaintForeground().

◆ m_add_file

wxString Slic3r::GUI::AuFile::m_add_file

◆ m_bitmap_excel

ScalableBitmap Slic3r::GUI::AuFile::m_bitmap_excel

Referenced by AuFile(), and msw_rescale().

◆ m_bitmap_pdf

ScalableBitmap Slic3r::GUI::AuFile::m_bitmap_pdf

Referenced by AuFile(), and msw_rescale().

◆ m_bitmap_txt

ScalableBitmap Slic3r::GUI::AuFile::m_bitmap_txt

Referenced by AuFile(), and msw_rescale().

◆ m_cover

bool Slic3r::GUI::AuFile::m_cover {false}
96{false};

Referenced by on_set_delete(), PaintForeground(), and set_cover().

◆ m_file_bitmap

ScalableBitmap Slic3r::GUI::AuFile::m_file_bitmap

◆ m_file_cover

ScalableBitmap Slic3r::GUI::AuFile::m_file_cover

◆ m_file_delete

ScalableBitmap Slic3r::GUI::AuFile::m_file_delete

◆ m_file_edit_mask

ScalableBitmap Slic3r::GUI::AuFile::m_file_edit_mask

◆ m_file_exit_rename

wxStaticBitmap* Slic3r::GUI::AuFile::m_file_exit_rename

◆ m_file_name

◆ m_file_path

boost::filesystem::path Slic3r::GUI::AuFile::m_file_path

◆ m_hover

bool Slic3r::GUI::AuFile::m_hover {false}
95{false};

Referenced by on_mouse_enter(), on_mouse_leave(), and PaintForeground().

◆ m_input_name

::TextInput* Slic3r::GUI::AuFile::m_input_name {nullptr}

◆ m_text_name

wxStaticText* Slic3r::GUI::AuFile::m_text_name {nullptr}

◆ m_type


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Auxiliary.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Auxiliary.cpp