Push Settings down so it's available to the plater (for color choices, etc).

This commit is contained in:
Joseph Lenox 2018-04-29 14:40:15 -05:00 committed by Joseph Lenox
parent 16c4146764
commit f44efd08b0
6 changed files with 31 additions and 10 deletions

View File

@ -12,9 +12,9 @@ wxEND_EVENT_TABLE()
MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size) MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: MainFrame(title, pos, size, nullptr) {} : MainFrame(title, pos, size, nullptr) {}
MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, std::shared_ptr<Settings> config) MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, std::shared_ptr<Settings> _gui_config)
: wxFrame(NULL, wxID_ANY, title, pos, size), loaded(false), : wxFrame(NULL, wxID_ANY, title, pos, size), loaded(false),
tabpanel(nullptr), controller(nullptr), plater(nullptr), gui_config(config), preset_editor_tabs(std::map<wxWindowID, PresetEditor*>()) tabpanel(nullptr), controller(nullptr), plater(nullptr), gui_config(_gui_config), preset_editor_tabs(std::map<wxWindowID, PresetEditor*>())
{ {
// Set icon to either the .ico if windows or png for everything else. // Set icon to either the .ico if windows or png for everything else.
if (the_os == OS::Windows) if (the_os == OS::Windows)
@ -105,7 +105,7 @@ void MainFrame::init_tabpanel()
wxTheApp->CallAfter([=] { this->tabpanel->SetSelection(0); }); wxTheApp->CallAfter([=] { this->tabpanel->SetSelection(0); });
}), panel->GetId()); }), 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")); this->controller = new Slic3r::GUI::Controller(panel, _("Controller"));
panel->AddPage(this->plater, this->plater->GetName()); panel->AddPage(this->plater, this->plater->GetName());

View File

@ -28,7 +28,7 @@ class MainFrame: public wxFrame
{ {
public: public:
MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size); MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, std::shared_ptr<Settings> gui_config); MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, std::shared_ptr<Settings> _gui_config);
private: private:
wxDECLARE_EVENT_TABLE(); wxDECLARE_EVENT_TABLE();

View File

@ -1,3 +1,5 @@
#include <memory>
#include "Plater.hpp" #include "Plater.hpp"
#include "Log.hpp" #include "Log.hpp"
@ -5,8 +7,8 @@ namespace Slic3r { namespace GUI {
const auto PROGRESS_BAR_EVENT = wxNewEventType(); const auto PROGRESS_BAR_EVENT = wxNewEventType();
Plater::Plater(wxWindow* parent, const wxString& title) : Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings> _settings) :
wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, title) wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, title), settings(_settings)
{ {
// Set callback for status event for worker threads // 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 # Initialize 2D preview canvas

View File

@ -16,22 +16,25 @@
#include "Plater/Plater2DObject.hpp" #include "Plater/Plater2DObject.hpp"
#include "Plater/Plate2D.hpp" #include "Plater/Plate2D.hpp"
#include "Settings.hpp"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
using UndoOperation = int; using UndoOperation = int;
class Plater2DObject; class Plater2DObject;
class Plate2D;
class Plater : public wxPanel class Plater : public wxPanel
{ {
public: public:
Plater(wxWindow* parent, const wxString& title); Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings> _settings);
void add(); void add();
private: private:
std::shared_ptr<Slic3r::Print> print {std::make_shared<Print>(Slic3r::Print())}; std::shared_ptr<Slic3r::Print> print {std::make_shared<Print>(Slic3r::Print())};
std::shared_ptr<Slic3r::Model> model {std::make_shared<Model>(Slic3r::Model())}; std::shared_ptr<Slic3r::Model> model {std::make_shared<Model>(Slic3r::Model())};
std::shared_ptr<Settings> settings {};
std::shared_ptr<Slic3r::Config> config { Slic3r::Config::new_from_defaults( std::shared_ptr<Slic3r::Config> config { Slic3r::Config::new_from_defaults(
{"bed_shape", "complete_objects", "extruder_clearance_radius", "skirts", "skirt_distance", {"bed_shape", "complete_objects", "extruder_clearance_radius", "skirts", "skirt_distance",

View File

@ -0,0 +1,12 @@
#include "Plater/Plate2D.hpp"
#include <wx/colour.h>
namespace Slic3r { namespace GUI {
Plate2D::Plate2D(wxWindow* parent, const wxSize& size, std::vector<Plater2DObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config, std::shared_ptr<Settings> _settings) :
wxPanel(parent, wxID_ANY, wxDefaultPosition, size, wxTAB_TRAVERSAL), objects(_objects), model(_model), config(_config), settings(_settings)
{
}
} } // Namespace Slic3r::GUI

View File

@ -6,6 +6,8 @@
#endif #endif
#include <vector> #include <vector>
#include "Plater.hpp" #include "Plater.hpp"
#include "ColorScheme.hpp"
#include "Settings.hpp"
#include "Plater/Plater2DObject.hpp" #include "Plater/Plater2DObject.hpp"
@ -13,12 +15,14 @@ namespace Slic3r { namespace GUI {
class Plate2D : public wxPanel { class Plate2D : public wxPanel {
public: public:
Plate2D(wxWindow* parent, const wxSize& size, std::vector<Plater2DObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config) : Plate2D(wxWindow* parent, const wxSize& size, std::vector<Plater2DObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config, std::shared_ptr<Settings> _settings);
wxPanel(parent, wxID_ANY, wxDefaultPosition, size, wxTAB_TRAVERSAL), objects(_objects), model(_model), config(_config) { }
private: private:
std::vector<Plater2DObject>& objects; std::vector<Plater2DObject>& objects;
std::shared_ptr<Slic3r::Model> model; std::shared_ptr<Slic3r::Model> model;
std::shared_ptr<Slic3r::Config> config; std::shared_ptr<Slic3r::Config> config;
std::shared_ptr<Settings> settings;
wxBrush objects_brush {};
}; };
} } // Namespace Slic3r::GUI } } // Namespace Slic3r::GUI