diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 12ac4a3b3..361074ea3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -186,6 +186,7 @@ IF(wxWidgets_FOUND) ${GUI_LIBDIR}/GUI.cpp ${GUI_LIBDIR}/MainFrame.cpp ${GUI_LIBDIR}/Plater.cpp + ${GUI_LIBDIR}/Plater/Plate2D.cpp ${GUI_LIBDIR}/Settings.cpp ${GUI_LIBDIR}/misc_ui.cpp ) diff --git a/src/GUI/Plater.cpp b/src/GUI/Plater.cpp index ad887cf41..75d6fee1d 100644 --- a/src/GUI/Plater.cpp +++ b/src/GUI/Plater.cpp @@ -1,12 +1,20 @@ #include "Plater.hpp" +#include "Log.hpp" 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), - print(Slic3r::Print()) + wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, title) { + // Set callback for status event for worker threads + /* + this->print->set_status_cb([=](std::string percent percent, std::wstring message) { + wxPostEvent(this, new wxPlThreadEvent(-1, PROGRESS_BAR_EVENT, + }); + */ auto on_select_object { [=](uint32_t& obj_idx) { // this->select_object(obj_idx); } }; @@ -44,6 +52,10 @@ Plater::Plater(wxWindow* parent, const wxString& title) : $self->{preview3D}->canvas->set_viewport_from_scene($self->{canvas3D}); }); } + */ + canvas2D = new Plate2D(preview_notebook, wxDefaultSize, objects, model, config); + + /* # Initialize 2D preview canvas $self->{canvas} = Slic3r::GUI::Plater::2D->new($self->{preview_notebook}, wxDefaultSize, $self->{objects}, $self->{model}, $self->{config}); $self->{preview_notebook}->AddPage($self->{canvas}, '2D'); @@ -51,7 +63,6 @@ Plater::Plater(wxWindow* parent, const wxString& title) : $self->{canvas}->on_double_click($on_double_click); $self->{canvas}->on_right_click(sub { $on_right_click->($self->{canvas}, @_); }); $self->{canvas}->on_instances_moved($on_instances_moved); - # Initialize 3D toolpaths preview $self->{preview3D_page_idx} = -1; if ($Slic3r::GUI::have_OpenGL) { @@ -94,7 +105,7 @@ Plater::Plater(wxWindow* parent, const wxString& title) : } void Plater::add() { - + Log::info("GUI", L"Called Add function"); } diff --git a/src/GUI/Plater.hpp b/src/GUI/Plater.hpp index a22d7acf6..f0c4569f3 100644 --- a/src/GUI/Plater.hpp +++ b/src/GUI/Plater.hpp @@ -12,6 +12,10 @@ #include "libslic3r.h" #include "Model.hpp" #include "Print.hpp" +#include "Config.hpp" + +#include "Plater/Plater2DObject.hpp" +#include "Plater/Plate2D.hpp" namespace Slic3r { namespace GUI { @@ -26,28 +30,28 @@ public: void add(); private: - Print print; - Model model; + std::shared_ptr print {std::make_shared(Slic3r::Print())}; + std::shared_ptr model {std::make_shared(Slic3r::Model())}; + + std::shared_ptr config { Slic3r::Config::new_from_defaults( + {"bed_shape", "complete_objects", "extruder_clearance_radius", "skirts", "skirt_distance", + "brim_width", "serial_port", "serial_speed", "host_type", "print_host", "octoprint_apikey", + "shortcuts", "filament_colour"})}; bool processed {false}; - std::vector objects; + std::vector objects {}; std::stack undo {}; std::stack redo {}; wxNotebook* preview_notebook {new wxNotebook(this, -1, wxDefaultPosition, wxSize(335,335), wxNB_BOTTOM)}; + Plate2D* canvas2D {}; + }; -// 2D Preview of an object -class Plater2DObject { -public: - std::string name {""}; - std::string identifier {""}; - bool selected {false}; -}; } } // Namespace Slic3r::GUI diff --git a/src/GUI/Plater/Plate2D.cpp b/src/GUI/Plater/Plate2D.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/src/GUI/Plater/Plate2D.hpp b/src/GUI/Plater/Plate2D.hpp new file mode 100644 index 000000000..306d5cba1 --- /dev/null +++ b/src/GUI/Plater/Plate2D.hpp @@ -0,0 +1,25 @@ +#ifndef PLATE2D_HPP +#define PLATE2D_HPP +#include +#ifndef WX_PRECOMP + #include +#endif +#include +#include "Plater.hpp" +#include "Plater/Plater2DObject.hpp" + + +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) { } +private: + std::vector& objects; + std::shared_ptr model; + std::shared_ptr config; +}; + +} } // Namespace Slic3r::GUI +#endif // PLATE2D_HPP diff --git a/src/GUI/Plater/Plater2DObject.hpp b/src/GUI/Plater/Plater2DObject.hpp new file mode 100644 index 000000000..3a1772cfb --- /dev/null +++ b/src/GUI/Plater/Plater2DObject.hpp @@ -0,0 +1,13 @@ +#ifndef PLATER2DOBJECT_HPP +#define PLATER2DOBJECT_HPP + +namespace Slic3r { namespace GUI { +// 2D Preview of an object +class Plater2DObject { +public: + std::string name {""}; + std::string identifier {""}; + bool selected {false}; +}; +} } // Namespace Slic3r::GUI +#endif