Further implementation of Plater and Plater2D.

This commit is contained in:
Joseph Lenox 2018-04-29 12:16:31 -05:00
parent d02516d8fe
commit d07aaa87fd
6 changed files with 68 additions and 14 deletions

View File

@ -186,6 +186,7 @@ IF(wxWidgets_FOUND)
${GUI_LIBDIR}/GUI.cpp ${GUI_LIBDIR}/GUI.cpp
${GUI_LIBDIR}/MainFrame.cpp ${GUI_LIBDIR}/MainFrame.cpp
${GUI_LIBDIR}/Plater.cpp ${GUI_LIBDIR}/Plater.cpp
${GUI_LIBDIR}/Plater/Plate2D.cpp
${GUI_LIBDIR}/Settings.cpp ${GUI_LIBDIR}/Settings.cpp
${GUI_LIBDIR}/misc_ui.cpp ${GUI_LIBDIR}/misc_ui.cpp
) )

View File

@ -1,12 +1,20 @@
#include "Plater.hpp" #include "Plater.hpp"
#include "Log.hpp"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
const auto PROGRESS_BAR_EVENT = wxNewEventType();
Plater::Plater(wxWindow* parent, const wxString& title) : Plater::Plater(wxWindow* parent, const wxString& title) :
wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, title), wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, title)
print(Slic3r::Print())
{ {
// 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) { auto on_select_object { [=](uint32_t& obj_idx) {
// this->select_object(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}); $self->{preview3D}->canvas->set_viewport_from_scene($self->{canvas3D});
}); });
} }
*/
canvas2D = new Plate2D(preview_notebook, wxDefaultSize, objects, model, config);
/*
# Initialize 2D preview canvas # Initialize 2D preview canvas
$self->{canvas} = Slic3r::GUI::Plater::2D->new($self->{preview_notebook}, wxDefaultSize, $self->{objects}, $self->{model}, $self->{config}); $self->{canvas} = Slic3r::GUI::Plater::2D->new($self->{preview_notebook}, wxDefaultSize, $self->{objects}, $self->{model}, $self->{config});
$self->{preview_notebook}->AddPage($self->{canvas}, '2D'); $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_double_click($on_double_click);
$self->{canvas}->on_right_click(sub { $on_right_click->($self->{canvas}, @_); }); $self->{canvas}->on_right_click(sub { $on_right_click->($self->{canvas}, @_); });
$self->{canvas}->on_instances_moved($on_instances_moved); $self->{canvas}->on_instances_moved($on_instances_moved);
# Initialize 3D toolpaths preview # Initialize 3D toolpaths preview
$self->{preview3D_page_idx} = -1; $self->{preview3D_page_idx} = -1;
if ($Slic3r::GUI::have_OpenGL) { if ($Slic3r::GUI::have_OpenGL) {
@ -94,7 +105,7 @@ Plater::Plater(wxWindow* parent, const wxString& title) :
} }
void Plater::add() { void Plater::add() {
Log::info("GUI", L"Called Add function");
} }

View File

@ -12,6 +12,10 @@
#include "libslic3r.h" #include "libslic3r.h"
#include "Model.hpp" #include "Model.hpp"
#include "Print.hpp" #include "Print.hpp"
#include "Config.hpp"
#include "Plater/Plater2DObject.hpp"
#include "Plater/Plate2D.hpp"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
@ -26,28 +30,28 @@ public:
void add(); void add();
private: private:
Print print; std::shared_ptr<Slic3r::Print> print {std::make_shared<Print>(Slic3r::Print())};
Model model; std::shared_ptr<Slic3r::Model> model {std::make_shared<Model>(Slic3r::Model())};
std::shared_ptr<Slic3r::Config> 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}; bool processed {false};
std::vector<Plater2DObject> objects; std::vector<Plater2DObject> objects {};
std::stack<UndoOperation> undo {}; std::stack<UndoOperation> undo {};
std::stack<UndoOperation> redo {}; std::stack<UndoOperation> redo {};
wxNotebook* preview_notebook {new wxNotebook(this, -1, wxDefaultPosition, wxSize(335,335), wxNB_BOTTOM)}; 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 } } // Namespace Slic3r::GUI

View File

View File

@ -0,0 +1,25 @@
#ifndef PLATE2D_HPP
#define PLATE2D_HPP
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <vector>
#include "Plater.hpp"
#include "Plater/Plater2DObject.hpp"
namespace Slic3r { namespace GUI {
class Plate2D : public wxPanel {
public:
Plate2D(wxWindow* parent, const wxSize& size, std::vector<Plater2DObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config) :
wxPanel(parent, wxID_ANY, wxDefaultPosition, size, wxTAB_TRAVERSAL), objects(_objects), model(_model), config(_config) { }
private:
std::vector<Plater2DObject>& objects;
std::shared_ptr<Slic3r::Model> model;
std::shared_ptr<Slic3r::Config> config;
};
} } // Namespace Slic3r::GUI
#endif // PLATE2D_HPP

View File

@ -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