From 148316f21192818524e4959f8b007e6edf063ff8 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Tue, 15 May 2018 20:17:12 -0500 Subject: [PATCH] Stubbed in Plater menu. --- src/GUI/MainFrame.cpp | 30 ++++++++++++++++++++++++++++-- src/GUI/MainFrame.hpp | 8 ++++++++ src/GUI/Plater.cpp | 14 ++++++++------ src/GUI/Plater.hpp | 20 ++++++++++++++++++-- 4 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/GUI/MainFrame.cpp b/src/GUI/MainFrame.cpp index e1facce0f..28fecd971 100644 --- a/src/GUI/MainFrame.cpp +++ b/src/GUI/MainFrame.cpp @@ -118,11 +118,37 @@ void MainFrame::init_menubar() append_menu_item(menuFile, _(L"Open STL/OBJ/AMF/3MF…"), _("Open a model"), [=](wxCommandEvent& e) { if (this->plater != nullptr) this->plater->add();}, wxID_ANY, "brick_add.png", "Ctrl+O"); } - wxMenu* menuPlater = new wxMenu(); + wxMenu* menuPlater = this->plater_menu = new wxMenu(); { - append_menu_item(menuPlater, _(L"Arrange…"), _("Arrange models on plater"), [this](wxCommandEvent& e) { if (this->plater != nullptr) this->plater->arrange();}, wxID_ANY, "bricks.png", "Ctrl+G"); + wxMenu* selectMenu = this->plater_select_menu = new wxMenu(); + append_submenu(menuPlater, _("Select"), _("Select an object in the plater"), selectMenu, wxID_ANY, "brick.png"); + append_menu_item(menuPlater, _("Undo"), _("Undo"), [this](wxCommandEvent& e) { this->plater->undo(); }, wxID_ANY, "arrow_undo.png", "Ctrl+Z"); + append_menu_item(menuPlater, _("Redo"), _("Redo"), [this](wxCommandEvent& e) { this->plater->redo(); }, wxID_ANY, "arrow_redo.png", "Ctrl+Shift+Z"); + append_menu_item(menuPlater, _("Select Next Object"), _("Select Next Object in the plater"), + [this](wxCommandEvent& e) { this->plater->select_next(); }, wxID_ANY, "arrow_right.png", "Ctrl+Right"); + append_menu_item(menuPlater, _("Select Prev Object"), _("Select Previous Object in the plater"), + [this](wxCommandEvent& e) { this->plater->select_prev(); }, wxID_ANY, "arrow_left.png", "Ctrl+Left"); + append_menu_item(menuPlater, _("Zoom In"), _("Zoom In"), + [this](wxCommandEvent& e) { this->plater->zoom(Zoom::In); }, wxID_ANY, "zoom_in.png", "Ctrl+Up"); + append_menu_item(menuPlater, _("Zoom Out"), _("Zoom Out"), + [this](wxCommandEvent& e) { this->plater->zoom(Zoom::In); }, wxID_ANY, "zoom_out.png", "Ctrl+Down"); + menuPlater->AppendSeparator(); + append_menu_item(menuPlater, _("Export G-code..."), _("Export current plate as G-code"), + [this](wxCommandEvent& e) { this->plater->export_gcode(); }, wxID_ANY, "cog_go.png"); + append_menu_item(menuPlater, _("Export plate as STL..."), _("Export current plate as STL"), + [this](wxCommandEvent& e) { this->plater->export_stl(); }, wxID_ANY, "brick_go.png"); + append_menu_item(menuPlater, _("Export plate with modifiers as AMF..."), _("Export current plate as AMF, including all modifier meshes"), + [this](wxCommandEvent& e) { this->plater->export_amf(); }, wxID_ANY, "brick_go.png"); + append_menu_item(menuPlater, _("Export plate with modifiers as 3MF..."), _("Export current plate as 3MF, including all modifier meshes"), + [this](wxCommandEvent& e) { this->plater->export_tmf(); }, wxID_ANY, "brick_go.png"); + + + } wxMenu* menuObject = this->plater->object_menu(); + this->on_plater_object_list_changed(false); + this->on_plater_selection_changed(false); + wxMenu* menuSettings = new wxMenu(); { } diff --git a/src/GUI/MainFrame.hpp b/src/GUI/MainFrame.hpp index 1838114bb..65b66649e 100644 --- a/src/GUI/MainFrame.hpp +++ b/src/GUI/MainFrame.hpp @@ -31,6 +31,9 @@ public: MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size); MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, std::shared_ptr _gui_config); ProgressStatusBar* statusbar {new ProgressStatusBar(this, -1)}; + + bool has_plater_menu() { return this->plater_menu != nullptr; } + wxMenu* plater_select_menu {nullptr}; private: wxDECLARE_EVENT_TABLE(); @@ -45,10 +48,15 @@ private: Controller* controller; Plater* plater; + wxMenu* plater_menu {nullptr}; + std::shared_ptr gui_config; std::map preset_editor_tabs; + void on_plater_object_list_changed(bool force) {}; + void on_plater_selection_changed(bool force) {}; + }; diff --git a/src/GUI/Plater.cpp b/src/GUI/Plater.cpp index 051949ca2..a87c11177 100644 --- a/src/GUI/Plater.cpp +++ b/src/GUI/Plater.cpp @@ -278,7 +278,7 @@ std::vector Plater::load_file(const std::string file, const int obj_idx_to_ } progress_dialog->Destroy(); - this->redo = std::stack(); + this->_redo = std::stack(); return obj_idx; } @@ -482,13 +482,15 @@ void Plater::selection_changed() { auto obj = this->selected_object(); bool have_sel {obj != this->objects.end()}; - /* - if (my $menu = $self->GetFrame->{plater_select_menu}) { - $_->Check(0) for $menu->GetMenuItems; - if ($have_sel) { - $menu->FindItemByPosition($obj_idx)->Check(1); + auto* menu {this->GetFrame()->plater_select_menu}; + if (menu != nullptr) { + for (auto* item : menu->GetMenuItems()) { + item->Check(false); } + if (have_sel) + menu->FindItemByPosition(obj->identifier)->Check(true); } + /* my $method = $have_sel ? 'Enable' : 'Disable'; $self->{"btn_$_"}->$method diff --git a/src/GUI/Plater.hpp b/src/GUI/Plater.hpp index d6d5977f6..aafad916e 100644 --- a/src/GUI/Plater.hpp +++ b/src/GUI/Plater.hpp @@ -7,6 +7,7 @@ #include #include +#include #include @@ -34,6 +35,10 @@ enum class UndoCmd { Remove, Add, Reset, Increase, Decrease, Rotate }; +enum class Zoom { + In, Out +}; + using ObjIdx = unsigned int; using ObjRef = std::vector::iterator; @@ -76,6 +81,17 @@ public: /// Create menu for object. wxMenu* object_menu(); + void undo() {}; + void redo() {}; + + void select_next() {}; + void select_prev() {}; + void zoom(Zoom dir) {}; + + void export_gcode() {}; + void export_amf() {}; + void export_tmf() {}; + void export_stl() {}; private: std::shared_ptr print {std::make_shared(Slic3r::Print())}; std::shared_ptr model {std::make_shared(Slic3r::Model())}; @@ -92,8 +108,8 @@ private: size_t object_identifier {0U}; //< Counter for adding objects to Slic3r. Increment after adding each object. - std::stack undo {}; - std::stack redo {}; + std::stack _undo {}; + std::stack _redo {}; wxNotebook* preview_notebook {new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxSize(335,335), wxNB_BOTTOM)}; wxBoxSizer* right_sizer {new wxBoxSizer(wxVERTICAL)};