diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index ac6961990..7e02c0fdd 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -89,8 +89,6 @@ set(SLIC3R_GUI_SOURCES GUI/GUI_ObjectSettings.hpp GUI/GUI_ObjectLayers.cpp GUI/GUI_ObjectLayers.hpp - GUI/LambdaObjectDialog.cpp - GUI/LambdaObjectDialog.hpp GUI/MeshUtils.cpp GUI/MeshUtils.hpp GUI/Tab.cpp diff --git a/src/slic3r/GUI/BedShapeDialog.cpp b/src/slic3r/GUI/BedShapeDialog.cpp index 343610eaa..f08b1a379 100644 --- a/src/slic3r/GUI/BedShapeDialog.cpp +++ b/src/slic3r/GUI/BedShapeDialog.cpp @@ -1,5 +1,6 @@ #include "BedShapeDialog.hpp" #include "GUI_App.hpp" +#include "OptionsGroup.hpp" #include #include diff --git a/src/slic3r/GUI/BedShapeDialog.hpp b/src/slic3r/GUI/BedShapeDialog.hpp index 1603df4af..b583eca4a 100644 --- a/src/slic3r/GUI/BedShapeDialog.hpp +++ b/src/slic3r/GUI/BedShapeDialog.hpp @@ -3,7 +3,6 @@ // The bed shape dialog. // The dialog opens from Print Settins tab->Bed Shape : Set... -#include "OptionsGroup.hpp" #include "GUI_Utils.hpp" #include "2DBed.hpp" #include "I18N.hpp" @@ -14,6 +13,8 @@ namespace Slic3r { namespace GUI { +class ConfigOptionsGroup; + using ConfigOptionsGroupShp = std::shared_ptr; class BedShapePanel : public wxPanel { diff --git a/src/slic3r/GUI/ConfigWizard_private.hpp b/src/slic3r/GUI/ConfigWizard_private.hpp index 49993bfb1..4fa9c472f 100644 --- a/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/src/slic3r/GUI/ConfigWizard_private.hpp @@ -24,6 +24,9 @@ #include "AppConfig.hpp" #include "PresetBundle.hpp" #include "BedShapeDialog.hpp" +#include "GUI.hpp" +#include "wxExtensions.hpp" + namespace fs = boost::filesystem; diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 57418d93c..a468c9f93 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -11,7 +11,6 @@ #include "Tab.hpp" #include "wxExtensions.hpp" #include "libslic3r/Model.hpp" -#include "LambdaObjectDialog.hpp" #include "GLCanvas3D.hpp" #include "Selection.hpp" diff --git a/src/slic3r/GUI/LambdaObjectDialog.cpp b/src/slic3r/GUI/LambdaObjectDialog.cpp deleted file mode 100644 index 3121e0f70..000000000 --- a/src/slic3r/GUI/LambdaObjectDialog.cpp +++ /dev/null @@ -1,201 +0,0 @@ -#include "LambdaObjectDialog.hpp" - -#include -#include -#include "OptionsGroup.hpp" -#include "GUI_App.hpp" -#include "I18N.hpp" - -namespace Slic3r -{ -namespace GUI -{ - -LambdaObjectDialog::LambdaObjectDialog(wxWindow* parent, - const wxString type_name): - m_type_name(type_name) -{ - Create(parent, wxID_ANY, _(L("Lambda Object")), - parent->GetScreenPosition(), wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER); - - // instead of double dim[3] = { 1.0, 1.0, 1.0 }; - object_parameters.dim[0] = 1.0; - object_parameters.dim[1] = 1.0; - object_parameters.dim[2] = 1.0; - - sizer = new wxBoxSizer(wxVERTICAL); - - // modificator options - if (m_type_name == wxEmptyString) { - m_modificator_options_book = new wxChoicebook( this, wxID_ANY, wxDefaultPosition, - wxDefaultSize, wxCHB_TOP); - sizer->Add(m_modificator_options_book, 1, wxEXPAND | wxALL, 10); - } - else { - m_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); - sizer->Add(m_panel, 1, wxEXPAND | wxALL, 10); - } - - ConfigOptionDef def; - def.width = 70; - auto optgroup = init_modificator_options_page(_(L("Box"))); - if (optgroup) { - optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) { - int opt_id = opt_key == "l" ? 0 : - opt_key == "w" ? 1 : - opt_key == "h" ? 2 : -1; - if (opt_id < 0) return; - object_parameters.dim[opt_id] = boost::any_cast(value); - }; - - def.type = coFloat; - def.set_default_value(new ConfigOptionFloat{ 1.0 }); - def.label = L("Length"); - Option option(def, "l"); - optgroup->append_single_option_line(option); - - def.label = L("Width"); - option = Option(def, "w"); - optgroup->append_single_option_line(option); - - def.label = L("Height"); - option = Option(def, "h"); - optgroup->append_single_option_line(option); - } - - optgroup = init_modificator_options_page(_(L("Cylinder"))); - if (optgroup) { - optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) { - int val = boost::any_cast(value); - if (opt_key == "cyl_r") - object_parameters.cyl_r = val; - else if (opt_key == "cyl_h") - object_parameters.cyl_h = val; - else return; - }; - - def.type = coInt; - def.set_default_value(new ConfigOptionInt{ 1 }); - def.label = L("Radius"); - auto option = Option(def, "cyl_r"); - optgroup->append_single_option_line(option); - - def.label = L("Height"); - option = Option(def, "cyl_h"); - optgroup->append_single_option_line(option); - } - - optgroup = init_modificator_options_page(_(L("Sphere"))); - if (optgroup) { - optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) { - if (opt_key == "sph_rho") - object_parameters.sph_rho = boost::any_cast(value); - else return; - }; - - def.type = coFloat; - def.set_default_value(new ConfigOptionFloat{ 1.0 }); - def.label = L("Rho"); - auto option = Option(def, "sph_rho"); - optgroup->append_single_option_line(option); - } - - optgroup = init_modificator_options_page(_(L("Slab"))); - if (optgroup) { - optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) { - double val = boost::any_cast(value); - if (opt_key == "slab_z") - object_parameters.slab_z = val; - else if (opt_key == "slab_h") - object_parameters.slab_h = val; - else return; - }; - - def.type = coFloat; - def.set_default_value(new ConfigOptionFloat{ 1.0 }); - def.label = L("Height"); - auto option = Option(def, "slab_h"); - optgroup->append_single_option_line(option); - - def.label = L("Initial Z"); - option = Option(def, "slab_z"); - optgroup->append_single_option_line(option); - } - - Bind(wxEVT_CHOICEBOOK_PAGE_CHANGED, ([this](wxCommandEvent e) - { - auto page_idx = m_modificator_options_book->GetSelection(); - if (page_idx < 0) return; - switch (page_idx) - { - case 0: - object_parameters.type = LambdaTypeBox; - break; - case 1: - object_parameters.type = LambdaTypeCylinder; - break; - case 2: - object_parameters.type = LambdaTypeSphere; - break; - case 3: - object_parameters.type = LambdaTypeSlab; - break; - default: - break; - } - })); - - const auto button_sizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL); - - wxButton* btn_OK = static_cast(FindWindowById(wxID_OK, this)); - btn_OK->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { - // validate user input - if (!CanClose())return; - EndModal(wxID_OK); - Destroy(); - }); - - wxButton* btn_CANCEL = static_cast(FindWindowById(wxID_CANCEL, this)); - btn_CANCEL->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { - // validate user input - if (!CanClose())return; - EndModal(wxID_CANCEL); - Destroy(); - }); - - sizer->Add(button_sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); - - SetSizer(sizer); - sizer->Fit(this); - sizer->SetSizeHints(this); -} - -// Called from the constructor. -// Create a panel for a rectangular / circular / custom bed shape. -ConfigOptionsGroupShp LambdaObjectDialog::init_modificator_options_page(const wxString& title) -{ - if (!m_type_name.IsEmpty() && m_type_name != title) - return nullptr; - - auto panel = m_type_name.IsEmpty() ? new wxPanel(m_modificator_options_book) : m_panel; - - ConfigOptionsGroupShp optgroup; - optgroup = std::make_shared(panel, _(L("Add")) + " " +title + " " +dots); - optgroup->label_width = 100; - - m_optgroups.push_back(optgroup); - - if (m_type_name.IsEmpty()) { - panel->SetSizerAndFit(optgroup->sizer); - m_modificator_options_book->AddPage(panel, title); - } - else - panel->SetSizer(optgroup->sizer); - - return optgroup; -} - - -} //namespace GUI -} //namespace Slic3r diff --git a/src/slic3r/GUI/LambdaObjectDialog.hpp b/src/slic3r/GUI/LambdaObjectDialog.hpp deleted file mode 100644 index 5bc2d19a5..000000000 --- a/src/slic3r/GUI/LambdaObjectDialog.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef slic3r_LambdaObjectDialog_hpp_ -#define slic3r_LambdaObjectDialog_hpp_ - -#include -#include - -#include -#include -#include - -class wxPanel; - -namespace Slic3r -{ -namespace GUI -{ -enum LambdaTypeIDs{ - LambdaTypeBox, - LambdaTypeCylinder, - LambdaTypeSphere, - LambdaTypeSlab -}; - -struct OBJECT_PARAMETERS -{ - LambdaTypeIDs type = LambdaTypeBox; - double dim[3];// = { 1.0, 1.0, 1.0 }; - int cyl_r = 1; - int cyl_h = 1; - double sph_rho = 1.0; - double slab_h = 1.0; - double slab_z = 0.0; -}; -class ConfigOptionsGroup; -using ConfigOptionsGroupShp = std::shared_ptr; -class LambdaObjectDialog : public wxDialog -{ - wxChoicebook* m_modificator_options_book = nullptr; - std::vector m_optgroups; - wxString m_type_name; - wxPanel* m_panel = nullptr; -public: - LambdaObjectDialog(wxWindow* parent, - const wxString type_name = wxEmptyString); - ~LambdaObjectDialog() {} - - bool CanClose() { return true; } // ??? - OBJECT_PARAMETERS& ObjectParameters() { return object_parameters; } - - ConfigOptionsGroupShp init_modificator_options_page(const wxString& title); - - // Note whether the window was already closed, so a pending update is not executed. - bool m_already_closed = false; - OBJECT_PARAMETERS object_parameters; - wxBoxSizer* sizer = nullptr; -}; -} //namespace GUI -} //namespace Slic3r -#endif //slic3r_LambdaObjectDialog_hpp_ diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 158553562..dd412a0de 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3584,6 +3584,18 @@ void Tab::set_tooltips_text() "Click to reset current value to the last saved preset.")); } +Page::Page(wxWindow* parent, const wxString& title, const int iconID, const std::vector& mode_bmp_cache) : + m_parent(parent), + m_title(title), + m_iconID(iconID), + m_mode_bitmap_cache(mode_bmp_cache) +{ + Create(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + m_vsizer = new wxBoxSizer(wxVERTICAL); + m_item_color = &wxGetApp().get_label_clr_default(); + SetSizer(m_vsizer); +} + void Page::reload_config() { for (auto group : m_optgroups) diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 71c3a55db..5805809bf 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -34,12 +34,11 @@ #include "wxExtensions.hpp" #include "ConfigManipulation.hpp" #include "Preset.hpp" -#include "GUI_App.hpp" +#include "OptionsGroup.hpp" namespace Slic3r { namespace GUI { - // Single Tab page containing a{ vsizer } of{ optgroups } // package Slic3r::GUI::Tab::Page; using ConfigOptionsGroupShp = std::shared_ptr; @@ -51,17 +50,8 @@ class Page : public wxScrolledWindow wxBoxSizer* m_vsizer; bool m_show = true; public: - Page(wxWindow* parent, const wxString& title, const int iconID, const std::vector& mode_bmp_cache) : - m_parent(parent), - m_title(title), - m_iconID(iconID), - m_mode_bitmap_cache(mode_bmp_cache) - { - Create(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); - m_vsizer = new wxBoxSizer(wxVERTICAL); - m_item_color = &wxGetApp().get_label_clr_default(); - SetSizer(m_vsizer); - } + Page(wxWindow* parent, const wxString& title, const int iconID, + const std::vector& mode_bmp_cache); ~Page() {} bool m_is_modified_values{ false };