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

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

Inheritance diagram for Slic3r::GUI::BedShapePanel:
Collaboration diagram for Slic3r::GUI::BedShapePanel:

Public Member Functions

 BedShapePanel (wxWindow *parent)
void build_panel (const Pointfs &default_pt, const std::string &custom_texture, const std::string &custom_model)
const Pointfs & get_shape () const
const std::string & get_custom_texture () const
const std::string & get_custom_model () const

Private Member Functions

ConfigOptionsGroupShp init_shape_options_page (const wxString &title)
void activate_options_page (ConfigOptionsGroupShp options_group)
wxPanel * init_texture_panel ()
wxPanel * init_model_panel ()
void set_shape (const Pointfs &points)
void update_preview ()
void update_shape ()
void load_stl ()
void load_texture ()
void load_model ()

Private Attributes

Bed_2D * m_canvas
Pointfs m_shape
Pointfs m_loaded_shape
std::string m_custom_texture
std::string m_custom_model
wxSimplebook * m_shape_options_book
ComboBox * m_shape_combo
std::vector< ConfigOptionsGroupShp > m_optgroups

Static Private Attributes

static const std::string NONE = "None"
static const std::string EMPTY_STRING = ""

Friends

class BedShapeDialog

Detailed Description

Constructor & Destructor Documentation

◆ BedShapePanel()

Slic3r::GUI::BedShapePanel::BedShapePanel ( wxWindow * parent)
inline
76: wxPanel(parent, wxID_ANY), m_custom_texture(NONE), m_custom_model(NONE) {}
static const std::string NONE
Definition BedShapeDialog.hpp:66
std::string m_custom_texture
Definition BedShapeDialog.hpp:72
std::string m_custom_model
Definition BedShapeDialog.hpp:73

References m_custom_model, m_custom_texture, and NONE.

Member Function Documentation

◆ activate_options_page()

void Slic3r::GUI::BedShapePanel::activate_options_page ( ConfigOptionsGroupShp options_group)
private
320{
321 options_group->activate();
322 options_group->parent()->SetSizerAndFit(options_group->sizer);
323}

Referenced by build_panel().

Here is the caller graph for this function:

◆ build_panel()

void Slic3r::GUI::BedShapePanel::build_panel ( const Pointfs & default_pt,
const std::string & custom_texture,
const std::string & custom_model )
212{
213 wxGetApp().UpdateDarkUI(this);
214 m_shape = make_counter_clockwise(default_pt);
215 m_custom_texture = custom_texture.empty() ? NONE : custom_texture;
216 m_custom_model = custom_model.empty() ? NONE : custom_model;
217
218 // ORCA match style of wxStaticBox between platforms
219 LabeledStaticBox* stb = new LabeledStaticBox(this, _L("Shape"));
220 auto sbsizer = new wxStaticBoxSizer(stb, wxVERTICAL);
221
222 // shape options
223 m_shape_options_book = new wxSimplebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
224 // ORCA replace wxChoicebook wxSimplebook and add a combo box for control
225 m_shape_combo = new ComboBox(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY);
229 m_shape_combo->SetSelection(int(BedShape(default_pt).get_page_type()));
230 m_shape_combo->GetDropDown().Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
231 if(m_shape_options_book->GetSelection() != evt.GetSelection()){
232 m_shape_options_book->ChangeSelection(evt.GetSelection());
233 update_shape();
234 }
235 evt.Skip();
236 });
237
238 sbsizer->Add(m_shape_combo, 0, wxALL | wxEXPAND, FromDIP(3));
239
240 sbsizer->Add(m_shape_options_book, 1, wxEXPAND);
241
245 activate_options_page(optgroup);
246
249 activate_options_page(optgroup);
250
252
253 Line line{ "", "" };
254 line.full_width = 1;
255 line.widget = [this](wxWindow* parent) {
256 Button* shape_btn = new Button(parent, _L("Load shape from STL..."));
258
259 wxSizer* shape_sizer = new wxBoxSizer(wxHORIZONTAL);
260 shape_sizer->Add(shape_btn, 1, wxEXPAND);
261
262 wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
263 sizer->Add(shape_sizer, 1, wxEXPAND);
264
265 shape_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {
266 load_stl();
267 });
268
269 return sizer;
270 };
271 optgroup->append_line(line);
272 activate_options_page(optgroup);
273
274 wxPanel* texture_panel = init_texture_panel();
275 wxPanel* model_panel = init_model_panel();
276
277 Bind(wxEVT_BOOKCTRL_PAGE_CHANGED, ([this](wxCommandEvent& e) { update_shape(); }));
278
279 // right pane with preview canvas
280 m_canvas = new Bed_2D(this);
281 m_canvas->Bind(wxEVT_PAINT, [this](wxPaintEvent& e) { m_canvas->repaint(m_shape); });
282 m_canvas->Bind(wxEVT_SIZE, [this](wxSizeEvent& e) { m_canvas->Refresh(); });
283
284 wxSizer* left_sizer = new wxBoxSizer(wxVERTICAL);
285 left_sizer->Add(sbsizer, 1, wxEXPAND);
286 left_sizer->Add(texture_panel, 1, wxEXPAND);
287 left_sizer->Add(model_panel, 1, wxEXPAND);
288
289 wxSizer* top_sizer = new wxBoxSizer(wxHORIZONTAL);
290 top_sizer->Add(left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 10);
291 top_sizer->Add(m_canvas, 1, wxEXPAND | wxALL, 10);
292
293 SetSizerAndFit(top_sizer);
294
297}
@ Regular
Definition Button.hpp:24
@ Expanded
Definition Button.hpp:38
#define _L(s)
Definition OBJ.cpp:34
void SetStyle(const ButtonStyle style, const ButtonType type)
Definition Button.cpp:200
wxSimplebook * m_shape_options_book
Definition BedShapeDialog.hpp:97
ConfigOptionsGroupShp init_shape_options_page(const wxString &title)
Definition BedShapeDialog.cpp:301
Pointfs m_shape
Definition BedShapeDialog.hpp:70
wxPanel * init_model_panel()
Definition BedShapeDialog.cpp:401
void update_preview()
Definition BedShapeDialog.cpp:500
void activate_options_page(ConfigOptionsGroupShp options_group)
Definition BedShapeDialog.cpp:319
void update_shape()
Definition BedShapeDialog.cpp:507
Bed_2D * m_canvas
Definition BedShapeDialog.hpp:69
wxPanel * init_texture_panel()
Definition BedShapeDialog.cpp:325
void load_stl()
Definition BedShapeDialog.cpp:574
void set_shape(const Pointfs &points)
Definition BedShapeDialog.cpp:484
ComboBox * m_shape_combo
Definition BedShapeDialog.hpp:98
Pointfs make_counter_clockwise(const Pointfs &pointfs)
Definition ClipperUtils.cpp:1568
static void append_option_line(ConfigOptionsGroupShp optgroup, Parameter param)
Definition BedShapeDialog.cpp:66
static wxString get_name(PageType type)
Definition BedShapeDialog.cpp:109
@ Circle
Definition BedShapeDialog.hpp:38
@ Custom
Definition BedShapeDialog.hpp:39
@ Rectangle
Definition BedShapeDialog.hpp:37
@ RectOrigin
Definition BedShapeDialog.hpp:44
@ RectSize
Definition BedShapeDialog.hpp:43
@ Diameter
Definition BedShapeDialog.hpp:45

References _L, activate_options_page(), Slic3r::GUI::BedShape::append_option_line(), Slic3r::GUI::BedShape::Circle, Slic3r::GUI::BedShape::Custom, Slic3r::GUI::BedShape::Diameter, Expanded, Slic3r::GUI::Line::full_width, Slic3r::GUI::BedShape::get_name(), init_model_panel(), init_shape_options_page(), init_texture_panel(), load_stl(), m_canvas, m_custom_model, m_custom_texture, m_shape, m_shape_combo, m_shape_options_book, Slic3r::make_counter_clockwise(), NONE, Slic3r::GUI::BedShape::Rectangle, Slic3r::GUI::BedShape::RectOrigin, Slic3r::GUI::BedShape::RectSize, Regular, set_shape(), Button::SetStyle(), update_preview(), update_shape(), and Slic3r::GUI::Line::widget.

Here is the call graph for this function:

◆ get_custom_model()

const std::string & Slic3r::GUI::BedShapePanel::get_custom_model ( ) const
inline
static const std::string EMPTY_STRING
Definition BedShapeDialog.hpp:67

References EMPTY_STRING, m_custom_model, and NONE.

◆ get_custom_texture()

const std::string & Slic3r::GUI::BedShapePanel::get_custom_texture ( ) const
inline

◆ get_shape()

const Pointfs & Slic3r::GUI::BedShapePanel::get_shape ( ) const
inline
81{ return m_shape; }

References m_shape.

◆ init_model_panel()

wxPanel * Slic3r::GUI::BedShapePanel::init_model_panel ( )
private
402{
403 wxPanel* panel = new wxPanel(this);
404 panel->SetBackgroundColour(*wxWHITE);
405 ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(panel, _L("Model"));
406
407 optgroup->label_width = 10;
408 optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
409 update_shape();
410 };
411
412
413 Line line{ "", "" };
414 line.full_width = 1;
415 line.widget = [this](wxWindow* parent) {
416 Button* load_btn = new Button(parent, _L("Load..."));
418
419 wxSizer* load_sizer = new wxBoxSizer(wxHORIZONTAL);
420 load_sizer->Add(load_btn, 1, wxEXPAND);
421
422 wxStaticText* filename_lbl = new wxStaticText(parent, wxID_ANY, _(NONE));
423 wxSizer* filename_sizer = new wxBoxSizer(wxHORIZONTAL);
424 filename_sizer->Add(filename_lbl, 1, wxEXPAND);
425
426 Button* remove_btn = new Button(parent, _L("Remove"));
428
429 wxSizer* remove_sizer = new wxBoxSizer(wxHORIZONTAL);
430 remove_sizer->Add(remove_btn, 1, wxEXPAND);
431
432 wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
433 sizer->Add(filename_sizer, 1, wxEXPAND);
434 sizer->Add(load_sizer, 1, wxEXPAND);
435 sizer->Add(remove_sizer, 1, wxEXPAND | wxTOP, 2);
436
437 load_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { load_model(); }));
438
439 remove_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) {
441 update_shape();
442 }));
443
444 filename_lbl->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent& e) {
445 e.SetText(_(boost::filesystem::path(m_custom_model).filename().string()));
446 wxStaticText* lbl = dynamic_cast<wxStaticText*>(e.GetEventObject());
447 if (lbl != nullptr) {
448 bool exists = (m_custom_model == NONE) || boost::filesystem::exists(m_custom_model);
449 lbl->SetForegroundColour(exists ? wxGetApp().get_label_clr_default() : wxColour("#E14747")); // ORCA
450
451 wxString tooltip_text = "";
452 if (m_custom_model != NONE) {
453 if (!exists)
454 tooltip_text += _L("Not found:") + " ";
455
456 tooltip_text += _(m_custom_model);
457 }
458
459 wxToolTip* tooltip = lbl->GetToolTip();
460 if ((tooltip == nullptr) || (tooltip->GetTip() != tooltip_text))
461 lbl->SetToolTip(tooltip_text);
462 }
463 }));
464
465 remove_btn->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent& e) { e.Enable(m_custom_model != NONE); }));
466
467 parent->SetBackgroundColour(*wxWHITE);
468
469 return sizer;
470 };
471 optgroup->append_line(line);
472 optgroup->activate();
473
474 panel->SetSizerAndFit(optgroup->sizer);
475
476 return panel;
477}
#define _(s)
Definition 3mf.cpp:306
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
void load_model()
Definition BedShapeDialog.cpp:641
std::shared_ptr< ConfigOptionsGroup > ConfigOptionsGroupShp
Definition BedShapeDialog.hpp:31
std::string t_config_option_key
Definition Config.hpp:96

References _, _L, Expanded, Slic3r::GUI::Line::full_width, load_model(), m_custom_model, NONE, Regular, Button::SetStyle(), update_shape(), Slic3r::GUI::Line::widget, and wxStaticText.

Referenced by build_panel().

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

◆ init_shape_options_page()

ConfigOptionsGroupShp Slic3r::GUI::BedShapePanel::init_shape_options_page ( const wxString & title)
private
302{
303 wxPanel* panel = new wxPanel(m_shape_options_book);
304 panel->SetBackgroundColour(*wxWHITE);
305 ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(panel, _L("Settings"));
306
307 optgroup->label_width = 10;
308 optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
309 update_shape();
310 };
311
312 m_optgroups.push_back(optgroup);
313// panel->SetSizerAndFit(optgroup->sizer);
314 m_shape_options_book->AddPage(panel, title);
315
316 return optgroup;
317}
std::vector< ConfigOptionsGroupShp > m_optgroups
Definition BedShapeDialog.hpp:99

References _L, m_optgroups, m_shape_options_book, and update_shape().

Referenced by build_panel().

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

◆ init_texture_panel()

wxPanel * Slic3r::GUI::BedShapePanel::init_texture_panel ( )
private
326{
327 wxPanel* panel = new wxPanel(this);
328 panel->SetBackgroundColour(*wxWHITE);
329 ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(panel, _L("Texture"));
330
331 optgroup->label_width = 10;
332 optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
333 update_shape();
334 };
335
336 Line line{ "", "" };
337 line.full_width = 1;
338 line.widget = [this](wxWindow* parent) {
339 Button* load_btn = new Button(parent, _L("Load..."));
341
342 wxSizer* load_sizer = new wxBoxSizer(wxHORIZONTAL);
343 load_sizer->Add(load_btn, 1, wxEXPAND);
344
345 wxStaticText* filename_lbl = new wxStaticText(parent, wxID_ANY, _(NONE));
346 wxSizer* filename_sizer = new wxBoxSizer(wxHORIZONTAL);
347 filename_sizer->Add(filename_lbl, 1, wxEXPAND);
348
349 Button* remove_btn = new Button(parent, _L("Remove"));
351
352 wxSizer* remove_sizer = new wxBoxSizer(wxHORIZONTAL);
353 remove_sizer->Add(remove_btn, 1, wxEXPAND);
354
355 wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
356 sizer->Add(filename_sizer, 1, wxEXPAND);
357 sizer->Add(load_sizer, 1, wxEXPAND);
358 sizer->Add(remove_sizer, 1, wxEXPAND | wxTOP, 2);
359
360 load_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { load_texture(); }));
361 remove_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) {
363 update_shape();
364 }));
365
366 filename_lbl->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent& e) {
367 e.SetText(_(boost::filesystem::path(m_custom_texture).filename().string()));
368 wxStaticText* lbl = dynamic_cast<wxStaticText*>(e.GetEventObject());
369 if (lbl != nullptr) {
370 bool exists = (m_custom_texture == NONE) || boost::filesystem::exists(m_custom_texture);
371 lbl->SetForegroundColour(exists ? wxGetApp().get_label_clr_default() : wxColour("#E14747")); // ORCA
372
373 wxString tooltip_text = "";
374 if (m_custom_texture != NONE) {
375 if (!exists)
376 tooltip_text += _L("Not found:") + " ";
377
378 tooltip_text += _(m_custom_texture);
379 }
380
381 wxToolTip* tooltip = lbl->GetToolTip();
382 if ((tooltip == nullptr) || (tooltip->GetTip() != tooltip_text))
383 lbl->SetToolTip(tooltip_text);
384 }
385 }));
386
387 remove_btn->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent& e) { e.Enable(m_custom_texture != NONE); }));
388
389 parent->SetBackgroundColour(*wxWHITE);
390
391 return sizer;
392 };
393 optgroup->append_line(line);
394 optgroup->activate();
395
396 panel->SetSizerAndFit(optgroup->sizer);
397
398 return panel;
399}
void load_texture()
Definition BedShapeDialog.cpp:619

References _, _L, Expanded, Slic3r::GUI::Line::full_width, load_texture(), m_custom_texture, NONE, Regular, Button::SetStyle(), update_shape(), Slic3r::GUI::Line::widget, and wxStaticText.

Referenced by build_panel().

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

◆ load_model()

void Slic3r::GUI::BedShapePanel::load_model ( )
private
642{
643 wxFileDialog dialog(this, _L("Choose an STL file to import bed model from:"), "", "",
644 file_wildcards(FT_STL), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
645
646 if (dialog.ShowModal() != wxID_OK)
647 return;
648
650
651 std::string file_name = dialog.GetPath().ToUTF8().data();
652 if (!boost::algorithm::iends_with(file_name, ".stl")) {
653 show_error(this, _L("Invalid file format."));
654 return;
655 }
656
657 wxBusyCursor wait;
658
659 m_custom_model = file_name;
660 update_shape();
661}
void show_error(wxWindow *parent, const wxString &message, bool has_code_excerpts)
Definition GUI.cpp:296
@ FT_STL
Definition GUI_App.hpp:121
wxString file_wildcards(FileType file_type, const std::string &custom_extension)
Definition GUI_App.cpp:695

References _L, Slic3r::GUI::file_wildcards(), Slic3r::GUI::FT_STL, m_custom_model, NONE, Slic3r::GUI::show_error(), and update_shape().

Referenced by init_model_panel().

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

◆ load_stl()

void Slic3r::GUI::BedShapePanel::load_stl ( )
private
575{
576 wxFileDialog dialog(this, _L("Choose an STL file to import bed shape from:"), "", "", file_wildcards(FT_STL), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
577 if (dialog.ShowModal() != wxID_OK)
578 return;
579
580 std::string file_name = dialog.GetPath().ToUTF8().data();
581 if (!boost::algorithm::iends_with(file_name, ".stl")) {
582 show_error(this, _L("Invalid file format."));
583 return;
584 }
585
586 wxBusyCursor wait;
587
588 Model model;
589 try {
590 model = Model::read_from_file(file_name);
591 }
592 catch (std::exception &) {
593 show_error(this, _L("Error: invalid model"));
594 return;
595 }
596
597 auto mesh = model.mesh();
598 auto expolygons = mesh.horizontal_projection();
599
600 if (expolygons.size() == 0) {
601 show_error(this, _L("The selected file contains no geometry."));
602 return;
603 }
604 if (expolygons.size() > 1) {
605 show_error(this, _L("The selected file contains several disjointed areas. This is not supported."));
606 return;
607 }
608
609 auto polygon = expolygons[0].contour;
610 polygon.make_counter_clockwise();
611 std::vector<Vec2d> points;
612 for (auto pt : polygon.points)
613 points.push_back(unscale(pt));
614
615 m_loaded_shape = points;
616 update_shape();
617}
Pointfs m_loaded_shape
Definition BedShapeDialog.hpp:71
static Model read_from_file(const std::string &input_file, DynamicPrintConfig *config=nullptr, ConfigSubstitutionContext *config_substitutions=nullptr, LoadStrategy options=LoadStrategy::AddDefaultInstances, PlateDataPtrs *plate_data=nullptr, std::vector< Preset * > *project_presets=nullptr, bool *is_xxx=nullptr, Semver *file_version=nullptr, Import3mfProgressFn proFn=nullptr, ImportstlProgressFn stlFn=nullptr, BBLProject *project=nullptr, int plate_id=0)
Definition Model.cpp:318
T unscale(Q v)
Definition libslic3r.h:138

References _L, Slic3r::GUI::file_wildcards(), Slic3r::GUI::FT_STL, Slic3r::TriangleMesh::horizontal_projection(), m_loaded_shape, Slic3r::Model::mesh(), Slic3r::Model::read_from_file(), Slic3r::GUI::show_error(), Slic3r::unscale(), and update_shape().

Referenced by build_panel().

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

◆ load_texture()

void Slic3r::GUI::BedShapePanel::load_texture ( )
private
620{
621 wxFileDialog dialog(this, _L("Choose a file to import bed texture from (PNG/SVG):"), "", "",
622 file_wildcards(FT_TEX), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
623
624 if (dialog.ShowModal() != wxID_OK)
625 return;
626
628
629 std::string file_name = dialog.GetPath().ToUTF8().data();
630 if (!boost::algorithm::iends_with(file_name, ".png") && !boost::algorithm::iends_with(file_name, ".svg")) {
631 show_error(this, _L("Invalid file format."));
632 return;
633 }
634
635 wxBusyCursor wait;
636
637 m_custom_texture = file_name;
638 update_shape();
639}
@ FT_TEX
Definition GUI_App.hpp:135

References _L, Slic3r::GUI::file_wildcards(), Slic3r::GUI::FT_TEX, m_custom_texture, NONE, Slic3r::GUI::show_error(), and update_shape().

Referenced by init_texture_panel().

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

◆ set_shape()

void Slic3r::GUI::BedShapePanel::set_shape ( const Pointfs & points)
private
485{
486 BedShape shape(points);
487
488 // Copy the polygon to the canvas, make a copy of the array, if custom shape is selected
489 if (shape.is_custom())
490 m_loaded_shape = points;
491
492 m_shape_options_book->SetSelection(int(shape.get_page_type()));
493 shape.apply_optgroup_values(m_optgroups[int(shape.get_page_type())]);
494
495 update_shape();
496
497 return;
498}

References Slic3r::GUI::BedShape::apply_optgroup_values(), Slic3r::GUI::BedShape::get_page_type(), Slic3r::GUI::BedShape::is_custom(), m_loaded_shape, m_optgroups, m_shape_options_book, and update_shape().

Referenced by build_panel().

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

◆ update_preview()

void Slic3r::GUI::BedShapePanel::update_preview ( )
private
501{
502 if (m_canvas) m_canvas->Refresh();
503 Refresh();
504}

References m_canvas.

Referenced by build_panel(), and update_shape().

Here is the caller graph for this function:

◆ update_shape()

void Slic3r::GUI::BedShapePanel::update_shape ( )
private
508{
509 auto page_idx = m_shape_options_book->GetSelection();
510 auto opt_group = m_optgroups[page_idx];
511
512 switch (static_cast<BedShape::PageType>(page_idx)) {
514 {
515 Vec2d rect_size(Vec2d::Zero());
516 Vec2d rect_origin(Vec2d::Zero());
517
518 try { rect_size = boost::any_cast<Vec2d>(opt_group->get_value("rect_size")); }
519 catch (const std::exception& /* e */) { return; }
520
521 try { rect_origin = boost::any_cast<Vec2d>(opt_group->get_value("rect_origin")); }
522 catch (const std::exception & /* e */) { return; }
523
524 auto x = rect_size(0);
525 auto y = rect_size(1);
526 // empty strings or '-' or other things
527 if (x == 0 || y == 0) return;
528 double x0 = 0.0;
529 double y0 = 0.0;
530 double x1 = x;
531 double y1 = y;
532
533 auto dx = rect_origin(0);
534 auto dy = rect_origin(1);
535
536 x0 -= dx;
537 x1 -= dx;
538 y0 -= dy;
539 y1 -= dy;
540 m_shape = { Vec2d(x0, y0),
541 Vec2d(x1, y0),
542 Vec2d(x1, y1),
543 Vec2d(x0, y1) };
544 break;
545 }
547 {
548 double diameter;
549 try { diameter = boost::any_cast<double>(opt_group->get_value("diameter")); }
550 catch (const std::exception & /* e */) { return; }
551
552 if (diameter == 0.0) return ;
553 auto r = diameter / 2;
554 auto twopi = 2 * PI;
555 // Don't change this value without adjusting BuildVolume constructor detecting circle diameter!
556 auto edges = 72;
557 std::vector<Vec2d> points;
558 for (int i = 1; i <= edges; ++i) {
559 auto angle = i * twopi / edges;
560 points.push_back(Vec2d(r*cos(angle), r*sin(angle)));
561 }
562 m_shape = points;
563 break;
564 }
567 break;
568 }
569
571}
static constexpr double PI
Definition libslic3r.h:81
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:138
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67
PageType
Definition BedShapeDialog.hpp:36

References Slic3r::angle(), Slic3r::GUI::BedShape::Circle, Slic3r::GUI::BedShape::Custom, m_loaded_shape, m_optgroups, m_shape, m_shape_options_book, PI, Slic3r::GUI::BedShape::Rectangle, and update_preview().

Referenced by build_panel(), init_model_panel(), init_shape_options_page(), init_texture_panel(), load_model(), load_stl(), load_texture(), and set_shape().

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

◆ BedShapeDialog

friend class BedShapeDialog
friend

References BedShapeDialog.

Referenced by BedShapeDialog.

Member Data Documentation

◆ EMPTY_STRING

const std::string Slic3r::GUI::BedShapePanel::EMPTY_STRING = ""
staticprivate

◆ m_canvas

Bed_2D* Slic3r::GUI::BedShapePanel::m_canvas
private

Referenced by build_panel(), and update_preview().

◆ m_custom_model

std::string Slic3r::GUI::BedShapePanel::m_custom_model
private

◆ m_custom_texture

std::string Slic3r::GUI::BedShapePanel::m_custom_texture
private

◆ m_loaded_shape

Pointfs Slic3r::GUI::BedShapePanel::m_loaded_shape
private

Referenced by load_stl(), set_shape(), and update_shape().

◆ m_optgroups

std::vector<ConfigOptionsGroupShp> Slic3r::GUI::BedShapePanel::m_optgroups
private

◆ m_shape

Pointfs Slic3r::GUI::BedShapePanel::m_shape
private

◆ m_shape_combo

ComboBox* Slic3r::GUI::BedShapePanel::m_shape_combo
private

Referenced by build_panel().

◆ m_shape_options_book

wxSimplebook* Slic3r::GUI::BedShapePanel::m_shape_options_book
private

◆ NONE

const std::string Slic3r::GUI::BedShapePanel::NONE = "None"
staticprivate

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