support generation when support point is added or removed. Rendering interface for SLA supports

This commit is contained in:
tamasmeszaros 2018-11-12 17:35:57 +01:00
parent 98a640ea06
commit 31967d0d1d
5 changed files with 76 additions and 2 deletions

View File

@ -196,6 +196,11 @@ void SLAPrint::process()
} }
} }
void SLAPrint::render_supports(SLASupportRenderer &renderer)
{
std::cout << "Would show the SLA supports" << std::endl;
}
SLAPrintObject::SLAPrintObject(SLAPrint *print, ModelObject *model_object): SLAPrintObject::SLAPrintObject(SLAPrint *print, ModelObject *model_object):
Inherited(print), Inherited(print),
m_model_object(model_object), m_model_object(model_object),

View File

@ -23,6 +23,7 @@ enum SLAPrintObjectStep {
}; };
class SLAPrint; class SLAPrint;
class GLCanvas;
using _SLAPrintObjectBase = using _SLAPrintObjectBase =
PrintObjectBaseWithState<SLAPrint, SLAPrintObjectStep, slaposCount>; PrintObjectBaseWithState<SLAPrint, SLAPrintObjectStep, slaposCount>;
@ -35,6 +36,7 @@ private: // Prevents erroneous use by other classes.
public: public:
const ModelObject* model_object() const { return m_model_object; } const ModelObject* model_object() const { return m_model_object; }
ModelObject* model_object() { return m_model_object; } ModelObject* model_object() { return m_model_object; }
TriangleMesh support_mesh() const;
// I refuse to grantee copying (Tamas) // I refuse to grantee copying (Tamas)
SLAPrintObject(const SLAPrintObject&) = delete; SLAPrintObject(const SLAPrintObject&) = delete;
@ -78,6 +80,37 @@ private:
std::unique_ptr<SupportData> m_supportdata; std::unique_ptr<SupportData> m_supportdata;
}; };
using PrintObjects = std::vector<SLAPrintObject*>;
class TriangleMesh;
class SLASupportRenderer {
public:
virtual ~SLASupportRenderer() {}
enum Buttons {
LEFT, RIGHT, MIDDLE
};
enum MType {
ENGAGE, RELEASE, HOVER
};
struct MouseEvt {
Buttons button; MType type;
};
using ClickCb = std::function<void(MouseEvt)>;
using Mesh = TriangleMesh;
virtual void add_pillar(const Mesh&, ClickCb on_mouse_evt) = 0;
virtual void add_head(const Mesh&, ClickCb on_mouse_evt) = 0;
virtual void add_bridge(const Mesh&, ClickCb on_mouse_evt) = 0;
virtual void add_junction(const Mesh&, ClickCb on_mouse_evt) = 0;
virtual void add_pad(const Mesh&, ClickCb on_mouse_evt) = 0;
};
/** /**
* @brief This class is the high level FSM for the SLA printing process. * @brief This class is the high level FSM for the SLA printing process.
* *
@ -108,11 +141,13 @@ public:
ApplyStatus apply(const Model &model, const DynamicPrintConfig &config) override; ApplyStatus apply(const Model &model, const DynamicPrintConfig &config) override;
void process() override; void process() override;
void render_supports(SLASupportRenderer& renderer);
private: private:
Model m_model; Model m_model;
SLAPrinterConfig m_printer_config; SLAPrinterConfig m_printer_config;
SLAMaterialConfig m_material_config; SLAMaterialConfig m_material_config;
std::vector<SLAPrintObject*> m_objects; PrintObjects m_objects;
friend SLAPrintObject; friend SLAPrintObject;
}; };

View File

@ -2,6 +2,7 @@
#include "GLGizmo.hpp" #include "GLGizmo.hpp"
#include "GUI.hpp" #include "GUI.hpp"
#include "GUI_App.hpp"
#include "../../libslic3r/Utils.hpp" #include "../../libslic3r/Utils.hpp"
@ -1663,6 +1664,9 @@ void GLGizmoSlaSupports::clicked_on_object(const Vec2d& mouse_position)
m_grabbers.push_back(Grabber()); m_grabbers.push_back(Grabber());
m_grabbers.back().center = new_pos.cast<double>(); m_grabbers.back().center = new_pos.cast<double>();
m_model_object->sla_support_points.push_back(new_pos); m_model_object->sla_support_points.push_back(new_pos);
// This should trigger the support generation
wxGetApp().plater()->reslice();
} }
catch (...) {} catch (...) {}
} }
@ -1672,12 +1676,18 @@ void GLGizmoSlaSupports::delete_current_grabber(bool delete_all)
if (delete_all) { if (delete_all) {
m_grabbers.clear(); m_grabbers.clear();
m_model_object->sla_support_points.clear(); m_model_object->sla_support_points.clear();
// This should trigger the support generation
wxGetApp().plater()->reslice();
} }
else else
if (m_hover_id != -1) { if (m_hover_id != -1) {
m_grabbers.erase(m_grabbers.begin() + m_hover_id); m_grabbers.erase(m_grabbers.begin() + m_hover_id);
m_model_object->sla_support_points.erase(m_model_object->sla_support_points.begin() + m_hover_id); m_model_object->sla_support_points.erase(m_model_object->sla_support_points.begin() + m_hover_id);
m_hover_id = -1; m_hover_id = -1;
// This should trigger the support generation
wxGetApp().plater()->reslice();
} }
} }

View File

@ -965,7 +965,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
background_process.set_sliced_event(EVT_SLICING_COMPLETED); background_process.set_sliced_event(EVT_SLICING_COMPLETED);
background_process.set_finished_event(EVT_PROCESS_COMPLETED); background_process.set_finished_event(EVT_PROCESS_COMPLETED);
// Default printer technology for default config. // Default printer technology for default config.
background_process.select_technology(wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology()); background_process.select_technology(q->printer_technology());
// Register progress callback from the Print class to the Platter. // Register progress callback from the Print class to the Platter.
print.set_status_callback([this](int percent, const std::string &message) { print.set_status_callback([this](int percent, const std::string &message) {
wxCommandEvent event(EVT_PROGRESS_BAR); wxCommandEvent event(EVT_PROGRESS_BAR);
@ -1786,6 +1786,21 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
// refresh preview // refresh preview
if (this->preview != nullptr) if (this->preview != nullptr)
this->preview->reload_print(); this->preview->reload_print();
// TODO: this needs to be implemented somehow
if(q->printer_technology() == PrinterTechnology::ptSLA) {
class Renderer: public SLASupportRenderer {
public:
void add_pillar(const Mesh&, ClickCb ) override {}
void add_head(const Mesh&, ClickCb) override {}
void add_bridge(const Mesh&, ClickCb) override {}
void add_junction(const Mesh&, ClickCb) override {}
void add_pad(const Mesh&, ClickCb) override {}
} renderer;
sla_print.render_supports(renderer);
}
} }
void Plater::priv::on_layer_editing_toggled(bool enable) void Plater::priv::on_layer_editing_toggled(bool enable)
@ -2331,6 +2346,11 @@ wxGLCanvas* Plater::canvas3D()
return p->canvas3D; return p->canvas3D;
} }
PrinterTechnology Plater::printer_technology() const
{
return wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
}
void Plater::changed_object(int obj_idx) void Plater::changed_object(int obj_idx)
{ {
if (obj_idx < 0) if (obj_idx < 0)

View File

@ -18,6 +18,8 @@ namespace Slic3r {
class Model; class Model;
class Print; class Print;
class SLAPrint;
namespace GUI { namespace GUI {
class MainFrame; class MainFrame;
@ -133,6 +135,8 @@ public:
int get_selected_object_idx(); int get_selected_object_idx();
wxGLCanvas* canvas3D(); wxGLCanvas* canvas3D();
PrinterTechnology printer_technology() const;
private: private:
struct priv; struct priv;
std::unique_ptr<priv> p; std::unique_ptr<priv> p;