From f44efd08b09b0678f92285183a2d78601ded5966 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sun, 29 Apr 2018 14:40:15 -0500 Subject: [PATCH] Push Settings down so it's available to the plater (for color choices, etc). --- src/GUI/MainFrame.cpp | 6 +++--- src/GUI/MainFrame.hpp | 2 +- src/GUI/Plater.cpp | 8 +++++--- src/GUI/Plater.hpp | 5 ++++- src/GUI/Plater/Plate2D.cpp | 12 ++++++++++++ src/GUI/Plater/Plate2D.hpp | 8 ++++++-- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/GUI/MainFrame.cpp b/src/GUI/MainFrame.cpp index 83eb2a65a..8c1d3c0e4 100644 --- a/src/GUI/MainFrame.cpp +++ b/src/GUI/MainFrame.cpp @@ -12,9 +12,9 @@ wxEND_EVENT_TABLE() MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : MainFrame(title, pos, size, nullptr) {} -MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, std::shared_ptr config) +MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, std::shared_ptr _gui_config) : wxFrame(NULL, wxID_ANY, title, pos, size), loaded(false), - tabpanel(nullptr), controller(nullptr), plater(nullptr), gui_config(config), preset_editor_tabs(std::map()) + tabpanel(nullptr), controller(nullptr), plater(nullptr), gui_config(_gui_config), preset_editor_tabs(std::map()) { // Set icon to either the .ico if windows or png for everything else. if (the_os == OS::Windows) @@ -105,7 +105,7 @@ void MainFrame::init_tabpanel() wxTheApp->CallAfter([=] { this->tabpanel->SetSelection(0); }); }), panel->GetId()); - this->plater = new Slic3r::GUI::Plater(panel, _("Plater")); + this->plater = new Slic3r::GUI::Plater(panel, _("Plater"), gui_config); this->controller = new Slic3r::GUI::Controller(panel, _("Controller")); panel->AddPage(this->plater, this->plater->GetName()); diff --git a/src/GUI/MainFrame.hpp b/src/GUI/MainFrame.hpp index 085cc3922..b067c6f9b 100644 --- a/src/GUI/MainFrame.hpp +++ b/src/GUI/MainFrame.hpp @@ -28,7 +28,7 @@ class MainFrame: public wxFrame { 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); + MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, std::shared_ptr _gui_config); private: wxDECLARE_EVENT_TABLE(); diff --git a/src/GUI/Plater.cpp b/src/GUI/Plater.cpp index 75d6fee1d..2fb6d323d 100644 --- a/src/GUI/Plater.cpp +++ b/src/GUI/Plater.cpp @@ -1,3 +1,5 @@ +#include + #include "Plater.hpp" #include "Log.hpp" @@ -5,8 +7,8 @@ namespace Slic3r { namespace GUI { const auto PROGRESS_BAR_EVENT = wxNewEventType(); -Plater::Plater(wxWindow* parent, const wxString& title) : - wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, title) +Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptr _settings) : + wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, title), settings(_settings) { // Set callback for status event for worker threads @@ -53,7 +55,7 @@ Plater::Plater(wxWindow* parent, const wxString& title) : }); } */ - canvas2D = new Plate2D(preview_notebook, wxDefaultSize, objects, model, config); + canvas2D = new Plate2D(preview_notebook, wxDefaultSize, objects, model, config, settings); /* # Initialize 2D preview canvas diff --git a/src/GUI/Plater.hpp b/src/GUI/Plater.hpp index f0c4569f3..e37448fdd 100644 --- a/src/GUI/Plater.hpp +++ b/src/GUI/Plater.hpp @@ -16,22 +16,25 @@ #include "Plater/Plater2DObject.hpp" #include "Plater/Plate2D.hpp" +#include "Settings.hpp" namespace Slic3r { namespace GUI { using UndoOperation = int; class Plater2DObject; +class Plate2D; class Plater : public wxPanel { public: - Plater(wxWindow* parent, const wxString& title); + Plater(wxWindow* parent, const wxString& title, std::shared_ptr _settings); void add(); private: std::shared_ptr print {std::make_shared(Slic3r::Print())}; std::shared_ptr model {std::make_shared(Slic3r::Model())}; + std::shared_ptr settings {}; std::shared_ptr config { Slic3r::Config::new_from_defaults( {"bed_shape", "complete_objects", "extruder_clearance_radius", "skirts", "skirt_distance", diff --git a/src/GUI/Plater/Plate2D.cpp b/src/GUI/Plater/Plate2D.cpp index e69de29bb..c5015b5d2 100644 --- a/src/GUI/Plater/Plate2D.cpp +++ b/src/GUI/Plater/Plate2D.cpp @@ -0,0 +1,12 @@ +#include "Plater/Plate2D.hpp" + +#include + +namespace Slic3r { namespace GUI { + +Plate2D::Plate2D(wxWindow* parent, const wxSize& size, std::vector& _objects, std::shared_ptr _model, std::shared_ptr _config, std::shared_ptr _settings) : + wxPanel(parent, wxID_ANY, wxDefaultPosition, size, wxTAB_TRAVERSAL), objects(_objects), model(_model), config(_config), settings(_settings) +{ +} + +} } // Namespace Slic3r::GUI diff --git a/src/GUI/Plater/Plate2D.hpp b/src/GUI/Plater/Plate2D.hpp index 306d5cba1..3c82f1a10 100644 --- a/src/GUI/Plater/Plate2D.hpp +++ b/src/GUI/Plater/Plate2D.hpp @@ -6,6 +6,8 @@ #endif #include #include "Plater.hpp" +#include "ColorScheme.hpp" +#include "Settings.hpp" #include "Plater/Plater2DObject.hpp" @@ -13,12 +15,14 @@ namespace Slic3r { namespace GUI { class Plate2D : public wxPanel { public: - Plate2D(wxWindow* parent, const wxSize& size, std::vector& _objects, std::shared_ptr _model, std::shared_ptr _config) : - wxPanel(parent, wxID_ANY, wxDefaultPosition, size, wxTAB_TRAVERSAL), objects(_objects), model(_model), config(_config) { } + Plate2D(wxWindow* parent, const wxSize& size, std::vector& _objects, std::shared_ptr _model, std::shared_ptr _config, std::shared_ptr _settings); private: std::vector& objects; std::shared_ptr model; std::shared_ptr config; + std::shared_ptr settings; + + wxBrush objects_brush {}; }; } } // Namespace Slic3r::GUI