mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-01 04:21:59 +08:00
Further implementation of Plater and Plater2D.
This commit is contained in:
parent
d02516d8fe
commit
d07aaa87fd
@ -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
|
||||
)
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<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::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};
|
||||
|
||||
std::vector<Plater2DObject> objects;
|
||||
std::vector<Plater2DObject> objects {};
|
||||
|
||||
std::stack<UndoOperation> undo {};
|
||||
std::stack<UndoOperation> 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
|
||||
|
||||
|
0
src/GUI/Plater/Plate2D.cpp
Normal file
0
src/GUI/Plater/Plate2D.cpp
Normal file
25
src/GUI/Plater/Plate2D.hpp
Normal file
25
src/GUI/Plater/Plate2D.hpp
Normal 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
|
13
src/GUI/Plater/Plater2DObject.hpp
Normal file
13
src/GUI/Plater/Plater2DObject.hpp
Normal 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
|
Loading…
x
Reference in New Issue
Block a user