SLA supports gizmo is now enabled and uses the new infrastructure

This commit is contained in:
Lukas Matena 2020-04-07 15:38:24 +02:00
parent c79e90b921
commit c704849a7a
6 changed files with 194 additions and 127 deletions

View file

@ -971,7 +971,7 @@ void GLGizmoHollow::on_set_state()
if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off
//Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned off"))); //Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned off")));
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_FORCE_UPDATE)); m_parent.post_event(SimpleEvent(EVT_GLCANVAS_FORCE_UPDATE));
m_parent.toggle_model_objects_visibility(true); //m_parent.toggle_model_objects_visibility(true);
//m_c->stash_clipping_plane(); //m_c->stash_clipping_plane();
//m_c->m_clipping_plane_distance = 0.f; //m_c->m_clipping_plane_distance = 0.f;
//update_clipping_plane(true); //update_clipping_plane(true);

View file

@ -3,6 +3,7 @@
#include "slic3r/GUI/GLCanvas3D.hpp" #include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/Camera.hpp" #include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Gizmos/GLGizmos.hpp" #include "slic3r/GUI/Gizmos/GLGizmos.hpp"
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
#include <GL/glew.h> #include <GL/glew.h>
@ -14,9 +15,6 @@
#include "slic3r/GUI/GUI.hpp" #include "slic3r/GUI/GUI.hpp"
#include "slic3r/GUI/GUI_ObjectSettings.hpp" #include "slic3r/GUI/GUI_ObjectSettings.hpp"
#include "slic3r/GUI/GUI_ObjectList.hpp" #include "slic3r/GUI/GUI_ObjectList.hpp"
#if ENABLE_NON_STATIC_CANVAS_MANAGER
#include "slic3r/GUI/Camera.hpp"
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
#include "slic3r/GUI/MeshUtils.hpp" #include "slic3r/GUI/MeshUtils.hpp"
#include "slic3r/GUI/Plater.hpp" #include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/PresetBundle.hpp" #include "slic3r/GUI/PresetBundle.hpp"
@ -66,6 +64,19 @@ bool GLGizmoSlaSupports::on_init()
void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const Selection& selection) void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const Selection& selection)
{ {
if (! m_c->selection_info())
return;
ModelObject* mo = m_c->selection_info()->model_object();
if (mo != m_old_mo) {
disable_editing_mode();
if (mo)
reload_cache();
m_old_mo = mo;
}
/*
if (m_c->recent_update) { if (m_c->recent_update) {
if (m_state == On) if (m_state == On)
m_c->build_AABB_if_needed(); m_c->build_AABB_if_needed();
@ -81,11 +92,11 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const S
m_parent.toggle_model_objects_visibility(false); m_parent.toggle_model_objects_visibility(false);
m_parent.toggle_model_objects_visibility(true, m_c->m_model_object, m_c->m_active_instance); m_parent.toggle_model_objects_visibility(true, m_c->m_model_object, m_c->m_active_instance);
m_parent.toggle_sla_auxiliaries_visibility(! m_editing_mode, m_c->m_model_object, m_c->m_active_instance); m_parent.toggle_sla_auxiliaries_visibility(! m_editing_mode, m_c->m_model_object, m_c->m_active_instance);
} }*/
// If we triggered autogeneration before, check backend and fetch results if they are there // If we triggered autogeneration before, check backend and fetch results if they are there
if (m_c->m_model_object) { if (mo) {
if (m_c->m_model_object->sla_points_status == sla::PointsStatus::Generating) if (mo->sla_points_status == sla::PointsStatus::Generating)
get_data_from_backend(); get_data_from_backend();
} }
} }
@ -94,13 +105,14 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const S
void GLGizmoSlaSupports::on_render() const void GLGizmoSlaSupports::on_render() const
{ {
ModelObject* mo = m_c->selection_info()->model_object();
const Selection& selection = m_parent.get_selection(); const Selection& selection = m_parent.get_selection();
// If current m_c->m_model_object does not match selection, ask GLCanvas3D to turn us off // If current m_c->m_model_object does not match selection, ask GLCanvas3D to turn us off
if (m_state == On if (m_state == On
&& (m_c->m_model_object != selection.get_model()->objects[selection.get_object_idx()] && (mo != selection.get_model()->objects[selection.get_object_idx()]
|| m_c->m_active_instance != selection.get_instance_idx() || m_c->selection_info()->get_active_instance() != selection.get_instance_idx()
|| m_c->m_model_object_id != m_c->m_model_object->id())) { /*|| m_c->m_model_object_id != m_c->m_model_object->id()*/)) {
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_RESETGIZMOS)); m_parent.post_event(SimpleEvent(EVT_GLCANVAS_RESETGIZMOS));
return; return;
} }
@ -108,20 +120,22 @@ void GLGizmoSlaSupports::on_render() const
glsafe(::glEnable(GL_BLEND)); glsafe(::glEnable(GL_BLEND));
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z(); // m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z();
if (m_quadric != nullptr && selection.is_from_single_instance()) if (m_quadric != nullptr && selection.is_from_single_instance())
render_points(selection, false); render_points(selection, false);
m_selection_rectangle.render(m_parent); m_selection_rectangle.render(m_parent);
render_clipping_plane(selection); m_c->object_clipper()->render_cut();
m_c->supports_clipper()->render_cut();
//render_clipping_plane(selection);
glsafe(::glDisable(GL_BLEND)); glsafe(::glDisable(GL_BLEND));
} }
void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection) const /*void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection) const
{ {
if (m_c->m_clipping_plane_distance == 0.f || m_c->m_mesh->empty()) if (m_c->m_clipping_plane_distance == 0.f || m_c->m_mesh->empty())
return; return;
@ -205,16 +219,17 @@ void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection) const
::glEnd(); ::glEnd();
::glPopMatrix(); ::glPopMatrix();
} }
} }*/
void GLGizmoSlaSupports::on_render_for_picking() const void GLGizmoSlaSupports::on_render_for_picking() const
{ {
const Selection& selection = m_parent.get_selection(); const Selection& selection = m_parent.get_selection();
/*
#if ENABLE_RENDER_PICKING_PASS #if ENABLE_RENDER_PICKING_PASS
m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z(); m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z();
#endif #endif
*/
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
render_points(selection, true); render_points(selection, true);
} }
@ -227,9 +242,10 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin());
const Transform3d& instance_scaling_matrix_inverse = vol->get_instance_transformation().get_matrix(true, true, false, true).inverse(); const Transform3d& instance_scaling_matrix_inverse = vol->get_instance_transformation().get_matrix(true, true, false, true).inverse();
const Transform3d& instance_matrix = vol->get_instance_transformation().get_matrix(); const Transform3d& instance_matrix = vol->get_instance_transformation().get_matrix();
float z_shift = m_c->selection_info()->get_sla_shift();
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glTranslated(0.0, 0.0, m_z_shift)); glsafe(::glTranslated(0.0, 0.0, z_shift));
glsafe(::glMultMatrixd(instance_matrix.data())); glsafe(::glMultMatrixd(instance_matrix.data()));
float render_color[4]; float render_color[4];
@ -285,7 +301,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
if (m_editing_mode) { if (m_editing_mode) {
// in case the normal is not yet cached, find and cache it // in case the normal is not yet cached, find and cache it
if (m_editing_cache[i].normal == Vec3f::Zero()) if (m_editing_cache[i].normal == Vec3f::Zero())
m_c->m_mesh_raycaster->get_closest_point(m_editing_cache[i].support_point.pos, &m_editing_cache[i].normal); m_c->raycaster()->raycaster()->get_closest_point(m_editing_cache[i].support_point.pos, &m_editing_cache[i].normal);
Eigen::Quaterniond q; Eigen::Quaterniond q;
q.setFromTwoVectors(Vec3d{0., 0., 1.}, instance_scaling_matrix_inverse * m_editing_cache[i].normal.cast<double>()); q.setFromTwoVectors(Vec3d{0., 0., 1.}, instance_scaling_matrix_inverse * m_editing_cache[i].normal.cast<double>());
@ -315,14 +331,15 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
} }
// Now render the drain holes: // Now render the drain holes:
if (! m_c->has_drilled_mesh()) { //if (! m_c->has_drilled_mesh()) {
if (! m_c->hollowed_mesh()->get_hollowed_mesh()) {
render_color[0] = 0.7f; render_color[0] = 0.7f;
render_color[1] = 0.7f; render_color[1] = 0.7f;
render_color[2] = 0.7f; render_color[2] = 0.7f;
render_color[3] = 0.7f; render_color[3] = 0.7f;
glsafe(::glColor4fv(render_color)); glsafe(::glColor4fv(render_color));
for (const sla::DrainHole& drain_hole : m_c->m_model_object->sla_drain_holes) { for (const sla::DrainHole& drain_hole : m_c->selection_info()->model_object()->sla_drain_holes) {
if (is_mesh_point_clipped((drain_hole.pos+m_c->HoleStickOutLength*drain_hole.normal).cast<double>())) if (is_mesh_point_clipped((drain_hole.pos+HoleStickOutLength*drain_hole.normal).cast<double>()))
continue; continue;
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
@ -365,12 +382,17 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
bool GLGizmoSlaSupports::is_mesh_point_clipped(const Vec3d& point) const bool GLGizmoSlaSupports::is_mesh_point_clipped(const Vec3d& point) const
{ {
if (m_c->m_clipping_plane_distance == 0.f) if (m_c->object_clipper()->get_position() == 0.)
return false; return false;
Vec3d transformed_point = m_c->m_model_object->instances[m_c->m_active_instance]->get_transformation().get_matrix() * point; auto sel_info = m_c->selection_info();
transformed_point(2) += m_z_shift; int active_inst = m_c->selection_info()->get_active_instance();
return m_c->m_clipping_plane->is_point_clipped(transformed_point); const ModelInstance* mi = sel_info->model_object()->instances[active_inst];
const Transform3d& trafo = mi->get_transformation().get_matrix();
Vec3d transformed_point = trafo * point;
transformed_point(2) += sel_info->get_sla_shift();
return m_c->object_clipper()->get_clipping_plane()->is_point_clipped(transformed_point);
} }
@ -379,7 +401,7 @@ bool GLGizmoSlaSupports::is_mesh_point_clipped(const Vec3d& point) const
// Return false if no intersection was found, true otherwise. // Return false if no intersection was found, true otherwise.
bool GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec3f, Vec3f>& pos_and_normal) bool GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec3f, Vec3f>& pos_and_normal)
{ {
if (! m_c->m_mesh_raycaster) if (! m_c->raycaster()->raycaster())
return false; return false;
#if ENABLE_NON_STATIC_CANVAS_MANAGER #if ENABLE_NON_STATIC_CANVAS_MANAGER
@ -390,26 +412,30 @@ bool GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec
const Selection& selection = m_parent.get_selection(); const Selection& selection = m_parent.get_selection();
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
Geometry::Transformation trafo = volume->get_instance_transformation(); Geometry::Transformation trafo = volume->get_instance_transformation();
trafo.set_offset(trafo.get_offset() + Vec3d(0., 0., m_z_shift)); trafo.set_offset(trafo.get_offset() + Vec3d(0., 0., m_c->selection_info()->get_sla_shift()));
double clp_dist = m_c->object_clipper()->get_position();
const ClippingPlane* clp = m_c->object_clipper()->get_clipping_plane();
// The raycaster query // The raycaster query
Vec3f hit; Vec3f hit;
Vec3f normal; Vec3f normal;
if (m_c->m_mesh_raycaster->unproject_on_mesh( if (m_c->raycaster()->raycaster()->unproject_on_mesh(
mouse_pos, mouse_pos,
trafo.get_matrix(), trafo.get_matrix(),
camera, camera,
hit, hit,
normal, normal,
m_c->m_clipping_plane_distance != 0.f ? m_c->m_clipping_plane.get() : nullptr)) clp_dist != 0. ? clp : nullptr))
{ {
// Check whether the hit is in a hole // Check whether the hit is in a hole
bool in_hole = false; bool in_hole = false;
// In case the hollowed and drilled mesh is available, we can allow // In case the hollowed and drilled mesh is available, we can allow
// placing points in holes, because they should never end up // placing points in holes, because they should never end up
// on surface that's been drilled away. // on surface that's been drilled away.
if (! m_c->has_drilled_mesh()) { if (! m_c->hollowed_mesh()->get_hollowed_mesh()) {
for (const sla::DrainHole& hole : m_c->m_model_object->sla_drain_holes) { sla::DrainHoles drain_holes = m_c->selection_info()->model_object()->sla_drain_holes;
for (const sla::DrainHole& hole : drain_holes) {
if (hole.is_inside(hit)) { if (hole.is_inside(hit)) {
in_hole = true; in_hole = true;
break; break;
@ -432,6 +458,9 @@ bool GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec
// concludes that the event was not intended for it, it should return false. // concludes that the event was not intended for it, it should return false.
bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down) bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down)
{ {
ModelObject* mo = m_c->selection_info()->model_object();
int active_inst = m_c->selection_info()->get_active_instance();
if (m_editing_mode) { if (m_editing_mode) {
// left down with shift - show the selection rectangle: // left down with shift - show the selection rectangle:
@ -483,8 +512,8 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
GLSelectionRectangle::EState rectangle_status = m_selection_rectangle.get_state(); GLSelectionRectangle::EState rectangle_status = m_selection_rectangle.get_state();
// First collect positions of all the points in world coordinates. // First collect positions of all the points in world coordinates.
Geometry::Transformation trafo = m_c->m_model_object->instances[m_c->m_active_instance]->get_transformation(); Geometry::Transformation trafo = mo->instances[active_inst]->get_transformation();
trafo.set_offset(trafo.get_offset() + Vec3d(0., 0., m_z_shift)); trafo.set_offset(trafo.get_offset() + Vec3d(0., 0., m_c->selection_info()->get_sla_shift()));
std::vector<Vec3d> points; std::vector<Vec3d> points;
for (unsigned int i=0; i<m_editing_cache.size(); ++i) for (unsigned int i=0; i<m_editing_cache.size(); ++i)
points.push_back(trafo.get_matrix() * m_editing_cache[i].support_point.pos.cast<double>()); points.push_back(trafo.get_matrix() * m_editing_cache[i].support_point.pos.cast<double>());
@ -496,11 +525,9 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
points_inside.push_back(points[idx].cast<float>()); points_inside.push_back(points[idx].cast<float>());
// Only select/deselect points that are actually visible // Only select/deselect points that are actually visible
#if ENABLE_NON_STATIC_CANVAS_MANAGER for (size_t idx : m_c->raycaster()->raycaster()->get_unobscured_idxs(
for (size_t idx : m_c->m_mesh_raycaster->get_unobscured_idxs(trafo, wxGetApp().plater()->get_camera(), points_inside, m_c->m_clipping_plane.get())) trafo, wxGetApp().plater()->get_camera(), points_inside,
#else m_c->object_clipper()->get_clipping_plane()))
for (size_t idx : m_c->m_mesh_raycaster->get_unobscured_idxs(trafo, m_parent.get_camera(), points_inside, m_c->m_clipping_plane.get()))
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
{ {
if (rectangle_status == GLSelectionRectangle::Deselect) if (rectangle_status == GLSelectionRectangle::Deselect)
unselect_point(points_idxs[idx]); unselect_point(points_idxs[idx]);
@ -577,20 +604,25 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
} }
if (action == SLAGizmoEventType::MouseWheelUp && control_down) { if (action == SLAGizmoEventType::MouseWheelUp && control_down) {
m_c->m_clipping_plane_distance = std::min(1.f, m_c->m_clipping_plane_distance + 0.01f); double pos = m_c->object_clipper()->get_position();
update_clipping_plane(m_c->m_clipping_plane_was_moved); pos = std::min(1., pos + 0.01);
m_c->m_clipping_plane_was_moved = true; m_c->object_clipper()->set_position(pos, true);
//update_clipping_plane(/*m_c->m_clipping_plane_was_moved*/);
//m_c->m_clipping_plane_was_moved = true;
return true; return true;
} }
if (action == SLAGizmoEventType::MouseWheelDown && control_down) { if (action == SLAGizmoEventType::MouseWheelDown && control_down) {
m_c->m_clipping_plane_distance = std::max(0.f, m_c->m_clipping_plane_distance - 0.01f); double pos = m_c->object_clipper()->get_position();
update_clipping_plane(true); pos = std::max(0., pos - 0.01);
m_c->object_clipper()->set_position(pos, true);
//update_clipping_plane(true);
return true; return true;
} }
if (action == SLAGizmoEventType::ResetClippingPlane) { if (action == SLAGizmoEventType::ResetClippingPlane) {
update_clipping_plane(); //update_clipping_plane();
m_c->object_clipper()->set_position(-1., false);
return true; return true;
} }
@ -634,11 +666,12 @@ void GLGizmoSlaSupports::on_update(const UpdateData& data)
std::vector<const ConfigOption*> GLGizmoSlaSupports::get_config_options(const std::vector<std::string>& keys) const std::vector<const ConfigOption*> GLGizmoSlaSupports::get_config_options(const std::vector<std::string>& keys) const
{ {
std::vector<const ConfigOption*> out; std::vector<const ConfigOption*> out;
const ModelObject* mo = m_c->selection_info()->model_object();
if (!m_c->m_model_object) if (! mo)
return out; return out;
const DynamicPrintConfig& object_cfg = m_c->m_model_object->config; const DynamicPrintConfig& object_cfg = mo->config;
const DynamicPrintConfig& print_cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config; const DynamicPrintConfig& print_cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
std::unique_ptr<DynamicPrintConfig> default_cfg = nullptr; std::unique_ptr<DynamicPrintConfig> default_cfg = nullptr;
@ -661,10 +694,18 @@ std::vector<const ConfigOption*> GLGizmoSlaSupports::get_config_options(const st
ClippingPlane GLGizmoSlaSupports::get_sla_clipping_plane() const ClippingPlane GLGizmoSlaSupports::get_sla_clipping_plane() const
{ {
if (!m_c->m_model_object || m_state == Off || m_c->m_clipping_plane_distance == 0.f) //if (!m_c->m_model_object || m_state == Off || m_c->m_clipping_plane_distance == 0.f)
// return ClippingPlane::ClipsNothing();
//else
// return ClippingPlane(-m_c->m_clipping_plane->get_normal(), m_c->m_clipping_plane->get_data()[3]);
if (! m_c->selection_info()->model_object()
|| m_state == Off
|| m_c->object_clipper()->get_position() == 0.)
return ClippingPlane::ClipsNothing(); return ClippingPlane::ClipsNothing();
else else {
return ClippingPlane(-m_c->m_clipping_plane->get_normal(), m_c->m_clipping_plane->get_data()[3]); const ClippingPlane& clp = *m_c->object_clipper()->get_clipping_plane();
return ClippingPlane(-clp.get_normal(), clp.get_data()[3]);
}
} }
@ -714,7 +755,9 @@ void GLGizmoSlaSupports::on_render_input_window(float x, float y, float bottom_l
static float last_y = 0.0f; static float last_y = 0.0f;
static float last_h = 0.0f; static float last_h = 0.0f;
if (! m_c->m_model_object) ModelObject* mo = m_c->selection_info()->model_object();
if (! mo)
return; return;
bool first_run = true; // This is a hack to redraw the button when all points are removed, bool first_run = true; // This is a hack to redraw the button when all points are removed,
@ -851,15 +894,15 @@ RENDER_AGAIN:
m_density_stash = density; m_density_stash = density;
} }
if (slider_edited) { if (slider_edited) {
m_c->m_model_object->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance; mo->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance;
m_c->m_model_object->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)density; mo->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)density;
} }
if (slider_released) { if (slider_released) {
m_c->m_model_object->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = m_minimal_point_distance_stash; mo->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = m_minimal_point_distance_stash;
m_c->m_model_object->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)m_density_stash; mo->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)m_density_stash;
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Support parameter change"))); Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Support parameter change")));
m_c->m_model_object->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance; mo->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance;
m_c->m_model_object->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)density; mo->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)density;
wxGetApp().obj_list()->update_and_show_object_settings_item(); wxGetApp().obj_list()->update_and_show_object_settings_item();
} }
@ -886,7 +929,7 @@ RENDER_AGAIN:
// Following is rendered in both editing and non-editing mode: // Following is rendered in both editing and non-editing mode:
ImGui::Separator(); ImGui::Separator();
if (m_c->m_clipping_plane_distance == 0.f) if (m_c->object_clipper()->get_position() == 0.f)
{ {
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
m_imgui->text(m_desc.at("clipping_of_view")); m_imgui->text(m_desc.at("clipping_of_view"));
@ -894,17 +937,17 @@ RENDER_AGAIN:
else { else {
if (m_imgui->button(m_desc.at("reset_direction"))) { if (m_imgui->button(m_desc.at("reset_direction"))) {
wxGetApp().CallAfter([this](){ wxGetApp().CallAfter([this](){
update_clipping_plane(); //update_clipping_plane();
m_c->object_clipper()->set_position(-1., false);
}); });
} }
} }
ImGui::SameLine(clipping_slider_left); ImGui::SameLine(clipping_slider_left);
ImGui::PushItemWidth(window_width - clipping_slider_left); ImGui::PushItemWidth(window_width - clipping_slider_left);
if (ImGui::SliderFloat(" ", &m_c->m_clipping_plane_distance, 0.f, 1.f, "%.2f")) { float clp_dist = m_c->object_clipper()->get_position();
update_clipping_plane(m_c->m_clipping_plane_was_moved); if (ImGui::SliderFloat(" ", &clp_dist, 0.f, 1.f, "%.2f"))
m_c->m_clipping_plane_was_moved = true; m_c->object_clipper()->set_position(clp_dist, true);
}
if (m_imgui->button("?")) { if (m_imgui->button("?")) {
@ -969,18 +1012,31 @@ std::string GLGizmoSlaSupports::on_get_name() const
} }
CommonGizmosDataID GLGizmoSlaSupports::on_get_requirements() const
{
return CommonGizmosDataID(
int(CommonGizmosDataID::SelectionInfo)
| int(CommonGizmosDataID::InstancesHider)
| int(CommonGizmosDataID::Raycaster)
| int(CommonGizmosDataID::HollowedMesh)
| int(CommonGizmosDataID::ObjectClipper)
| int(CommonGizmosDataID::SupportsClipper));
}
void GLGizmoSlaSupports::on_set_state() void GLGizmoSlaSupports::on_set_state()
{ {
const ModelObject* mo = m_c->selection_info()->model_object();
// m_c->m_model_object pointer can be invalid (for instance because of undo/redo action), // m_c->m_model_object pointer can be invalid (for instance because of undo/redo action),
// we should recover it from the object id // we should recover it from the object id
m_c->m_model_object = nullptr; /*m_c->m_model_object = nullptr;
for (const auto mo : wxGetApp().model().objects) { for (const auto mo : wxGetApp().model().objects) {
if (mo->id() == m_c->m_model_object_id) { if (mo->id() == m_c->m_model_object_id) {
m_c->m_model_object = mo; m_c->m_model_object = mo;
break; break;
} }
} }*/
if (m_state == m_old_state) if (m_state == m_old_state)
return; return;
@ -988,28 +1044,28 @@ void GLGizmoSlaSupports::on_set_state()
if (m_state == On && m_old_state != On) { // the gizmo was just turned on if (m_state == On && m_old_state != On) { // the gizmo was just turned on
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned on"))); Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned on")));
m_c->unstash_clipping_plane(); //m_c->unstash_clipping_plane();
update_clipping_plane(m_c->m_clipping_plane_was_moved); //update_clipping_plane(m_c->m_clipping_plane_was_moved);
m_c->build_AABB_if_needed(); //m_c->build_AABB_if_needed();
// we'll now reload support points: // we'll now reload support points:
if (m_c->m_model_object) if (mo)
reload_cache(); reload_cache();
m_parent.toggle_model_objects_visibility(false); /*m_parent.toggle_model_objects_visibility(false);
if (m_c->m_model_object) { if (m_c->m_model_object) {
m_parent.toggle_model_objects_visibility(true, m_c->m_model_object, m_c->m_active_instance); m_parent.toggle_model_objects_visibility(true, m_c->m_model_object, m_c->m_active_instance);
m_parent.toggle_sla_auxiliaries_visibility(! m_editing_mode, m_c->m_model_object, m_c->m_active_instance); m_parent.toggle_sla_auxiliaries_visibility(! m_editing_mode, m_c->m_model_object, m_c->m_active_instance);
} }*/
// Set default head diameter from config. // Set default head diameter from config.
const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config; const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
m_new_point_head_diameter = static_cast<const ConfigOptionFloat*>(cfg.option("support_head_front_diameter"))->value; m_new_point_head_diameter = static_cast<const ConfigOptionFloat*>(cfg.option("support_head_front_diameter"))->value;
} }
if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off
bool will_ask = m_c->m_model_object && m_editing_mode && unsaved_changes(); bool will_ask = mo && m_editing_mode && unsaved_changes();
if (will_ask) { if (will_ask) {
wxGetApp().CallAfter([this]() { wxGetApp().CallAfter([this]() {
// Following is called through CallAfter, because otherwise there was a problem // Following is called through CallAfter, because otherwise there was a problem
@ -1028,15 +1084,15 @@ void GLGizmoSlaSupports::on_set_state()
// we are actually shutting down // we are actually shutting down
disable_editing_mode(); // so it is not active next time the gizmo opens disable_editing_mode(); // so it is not active next time the gizmo opens
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned off"))); Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned off")));
m_parent.toggle_model_objects_visibility(true); //m_parent.toggle_model_objects_visibility(true);
m_normal_cache.clear(); m_normal_cache.clear();
m_c->stash_clipping_plane(); //m_c->stash_clipping_plane();
m_c->m_clipping_plane_distance = 0.f; //m_c->m_clipping_plane_distance = 0.f;
update_clipping_plane(true); //update_clipping_plane(true);
// Release clippers and the AABB raycaster. // Release clippers and the AABB raycaster.
m_its = nullptr; //m_its = nullptr;
m_c->m_object_clipper.reset(); //m_c->m_object_clipper.reset();
m_c->m_supports_clipper.reset(); //m_c->m_supports_clipper.reset();
//m_c->m_mesh_raycaster.reset(); //m_c->m_mesh_raycaster.reset();
} }
} }
@ -1077,10 +1133,7 @@ void GLGizmoSlaSupports::on_stop_dragging()
void GLGizmoSlaSupports::on_load(cereal::BinaryInputArchive& ar) void GLGizmoSlaSupports::on_load(cereal::BinaryInputArchive& ar)
{ {
ar(m_c->m_clipping_plane_distance, ar(m_new_point_head_diameter,
*m_c->m_clipping_plane,
m_c->m_model_object_id,
m_new_point_head_diameter,
m_normal_cache, m_normal_cache,
m_editing_cache, m_editing_cache,
m_selection_empty m_selection_empty
@ -1091,10 +1144,7 @@ void GLGizmoSlaSupports::on_load(cereal::BinaryInputArchive& ar)
void GLGizmoSlaSupports::on_save(cereal::BinaryOutputArchive& ar) const void GLGizmoSlaSupports::on_save(cereal::BinaryOutputArchive& ar) const
{ {
ar(m_c->m_clipping_plane_distance, ar(m_new_point_head_diameter,
*m_c->m_clipping_plane,
m_c->m_model_object_id,
m_new_point_head_diameter,
m_normal_cache, m_normal_cache,
m_editing_cache, m_editing_cache,
m_selection_empty m_selection_empty
@ -1171,9 +1221,10 @@ void GLGizmoSlaSupports::editing_mode_apply_changes()
for (const CacheEntry& ce : m_editing_cache) for (const CacheEntry& ce : m_editing_cache)
m_normal_cache.push_back(ce.support_point); m_normal_cache.push_back(ce.support_point);
m_c->m_model_object->sla_points_status = sla::PointsStatus::UserModified; ModelObject* mo = m_c->selection_info()->model_object();
m_c->m_model_object->sla_support_points.clear(); mo->sla_points_status = sla::PointsStatus::UserModified;
m_c->m_model_object->sla_support_points = m_normal_cache; mo->sla_support_points.clear();
mo->sla_support_points = m_normal_cache;
reslice_SLA_supports(); reslice_SLA_supports();
} }
@ -1183,23 +1234,25 @@ void GLGizmoSlaSupports::editing_mode_apply_changes()
void GLGizmoSlaSupports::reload_cache() void GLGizmoSlaSupports::reload_cache()
{ {
const ModelObject* mo = m_c->selection_info()->model_object();
m_normal_cache.clear(); m_normal_cache.clear();
if (m_c->m_model_object->sla_points_status == sla::PointsStatus::AutoGenerated || m_c->m_model_object->sla_points_status == sla::PointsStatus::Generating) if (mo->sla_points_status == sla::PointsStatus::AutoGenerated || mo->sla_points_status == sla::PointsStatus::Generating)
get_data_from_backend(); get_data_from_backend();
else else
for (const sla::SupportPoint& point : m_c->m_model_object->sla_support_points) for (const sla::SupportPoint& point : mo->sla_support_points)
m_normal_cache.emplace_back(point); m_normal_cache.emplace_back(point);
} }
bool GLGizmoSlaSupports::has_backend_supports() const bool GLGizmoSlaSupports::has_backend_supports() const
{ {
if (! m_c->m_model_object) const ModelObject* mo = m_c->selection_info()->model_object();
if (! mo)
return false; return false;
// find SlaPrintObject with this ID // find SlaPrintObject with this ID
for (const SLAPrintObject* po : m_parent.sla_print()->objects()) { for (const SLAPrintObject* po : m_parent.sla_print()->objects()) {
if (po->model_object()->id() == m_c->m_model_object->id()) if (po->model_object()->id() == mo->id())
return po->is_step_done(slaposSupportPoints); return po->is_step_done(slaposSupportPoints);
} }
return false; return false;
@ -1207,24 +1260,28 @@ bool GLGizmoSlaSupports::has_backend_supports() const
void GLGizmoSlaSupports::reslice_SLA_supports(bool postpone_error_messages) const void GLGizmoSlaSupports::reslice_SLA_supports(bool postpone_error_messages) const
{ {
wxGetApp().CallAfter([this, postpone_error_messages]() { wxGetApp().plater()->reslice_SLA_supports(*m_c->m_model_object, postpone_error_messages); }); wxGetApp().CallAfter([this, postpone_error_messages]() {
wxGetApp().plater()->reslice_SLA_supports(
*m_c->selection_info()->model_object(), postpone_error_messages);
});
} }
void GLGizmoSlaSupports::get_data_from_backend() void GLGizmoSlaSupports::get_data_from_backend()
{ {
if (! has_backend_supports()) if (! has_backend_supports())
return; return;
ModelObject* mo = m_c->selection_info()->model_object();
// find the respective SLAPrintObject, we need a pointer to it // find the respective SLAPrintObject, we need a pointer to it
for (const SLAPrintObject* po : m_parent.sla_print()->objects()) { for (const SLAPrintObject* po : m_parent.sla_print()->objects()) {
if (po->model_object()->id() == m_c->m_model_object->id()) { if (po->model_object()->id() == mo->id()) {
m_normal_cache.clear(); m_normal_cache.clear();
const std::vector<sla::SupportPoint>& points = po->get_support_points(); const std::vector<sla::SupportPoint>& points = po->get_support_points();
auto mat = po->trafo().inverse().cast<float>(); auto mat = po->trafo().inverse().cast<float>();
for (unsigned int i=0; i<points.size();++i) for (unsigned int i=0; i<points.size();++i)
m_normal_cache.emplace_back(sla::SupportPoint(mat * points[i].pos, points[i].head_front_radius, points[i].is_new_island)); m_normal_cache.emplace_back(sla::SupportPoint(mat * points[i].pos, points[i].head_front_radius, points[i].is_new_island));
m_c->m_model_object->sla_points_status = sla::PointsStatus::AutoGenerated; mo->sla_points_status = sla::PointsStatus::AutoGenerated;
break; break;
} }
} }
@ -1241,10 +1298,12 @@ void GLGizmoSlaSupports::auto_generate()
_(L("Are you sure you want to do it?")) + "\n", _(L("Are you sure you want to do it?")) + "\n",
_(L("Warning")), wxICON_WARNING | wxYES | wxNO); _(L("Warning")), wxICON_WARNING | wxYES | wxNO);
if (m_c->m_model_object->sla_points_status != sla::PointsStatus::UserModified || m_normal_cache.empty() || dlg.ShowModal() == wxID_YES) { ModelObject* mo = m_c->selection_info()->model_object();
if (mo->sla_points_status != sla::PointsStatus::UserModified || m_normal_cache.empty() || dlg.ShowModal() == wxID_YES) {
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Autogenerate support points"))); Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Autogenerate support points")));
wxGetApp().CallAfter([this]() { reslice_SLA_supports(); }); wxGetApp().CallAfter([this]() { reslice_SLA_supports(); });
m_c->m_model_object->sla_points_status = sla::PointsStatus::Generating; mo->sla_points_status = sla::PointsStatus::Generating;
} }
} }
@ -1259,7 +1318,8 @@ void GLGizmoSlaSupports::switch_to_editing_mode()
m_editing_cache.emplace_back(sp); m_editing_cache.emplace_back(sp);
select_point(NoPoints); select_point(NoPoints);
m_parent.toggle_sla_auxiliaries_visibility(false, m_c->m_model_object, m_c->m_active_instance); //m_parent.toggle_sla_auxiliaries_visibility(false, m_c->m_model_object, m_c->m_active_instance);
m_c->instances_hider()->show_supports(false);
m_parent.set_as_dirty(); m_parent.set_as_dirty();
} }
@ -1269,7 +1329,8 @@ void GLGizmoSlaSupports::disable_editing_mode()
if (m_editing_mode) { if (m_editing_mode) {
m_editing_mode = false; m_editing_mode = false;
wxGetApp().plater()->leave_gizmos_stack(); wxGetApp().plater()->leave_gizmos_stack();
m_parent.toggle_sla_auxiliaries_visibility(true, m_c->m_model_object, m_c->m_active_instance); //m_parent.toggle_sla_auxiliaries_visibility(true, m_c->m_model_object, m_c->m_active_instance);
m_c->instances_hider()->show_supports(true);
m_parent.set_as_dirty(); m_parent.set_as_dirty();
} }
} }
@ -1288,7 +1349,7 @@ bool GLGizmoSlaSupports::unsaved_changes() const
return false; return false;
} }
/*
void GLGizmoSlaSupports::update_clipping_plane(bool keep_normal) const void GLGizmoSlaSupports::update_clipping_plane(bool keep_normal) const
{ {
if (! m_c->m_model_object) if (! m_c->m_model_object)
@ -1306,7 +1367,7 @@ void GLGizmoSlaSupports::update_clipping_plane(bool keep_normal) const
float dist = normal.dot(center); float dist = normal.dot(center);
*m_c->m_clipping_plane = ClippingPlane(normal, (dist - (-m_c->m_active_instance_bb_radius) - m_c->m_clipping_plane_distance * 2*m_c->m_active_instance_bb_radius)); *m_c->m_clipping_plane = ClippingPlane(normal, (dist - (-m_c->m_active_instance_bb_radius) - m_c->m_clipping_plane_distance * 2*m_c->m_active_instance_bb_radius));
m_parent.set_as_dirty(); m_parent.set_as_dirty();
} }*/
SlaGizmoHelpDialog::SlaGizmoHelpDialog() SlaGizmoHelpDialog::SlaGizmoHelpDialog()
: wxDialog(nullptr, wxID_ANY, _(L("SLA gizmo keyboard shortcuts")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) : wxDialog(nullptr, wxID_ANY, _(L("SLA gizmo keyboard shortcuts")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)

View file

@ -16,7 +16,7 @@ namespace GUI {
class ClippingPlane; class ClippingPlane;
class MeshClipper; class MeshClipper;
class MeshRaycaster; class MeshRaycaster;
class CommonGizmosData; //class CommonGizmosData;
enum class SLAGizmoEventType : unsigned char; enum class SLAGizmoEventType : unsigned char;
class GLGizmoSlaSupports : public GLGizmoBase class GLGizmoSlaSupports : public GLGizmoBase
@ -26,7 +26,7 @@ private:
//ObjectID m_model_object_id = 0; //ObjectID m_model_object_id = 0;
//int m_active_instance = -1; //int m_active_instance = -1;
//float m_active_instance_bb_radius; // to cache the bb //float m_active_instance_bb_radius; // to cache the bb
mutable double m_z_shift = 0.f; //mutable double m_z_shift = 0.f;
bool unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec3f, Vec3f>& pos_and_normal); bool unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec3f, Vec3f>& pos_and_normal);
const float RenderPointScale = 1.f; const float RenderPointScale = 1.f;
@ -81,8 +81,8 @@ public:
bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); } bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); }
bool has_backend_supports() const; bool has_backend_supports() const;
void reslice_SLA_supports(bool postpone_error_messages = false) const; void reslice_SLA_supports(bool postpone_error_messages = false) const;
void update_clipping_plane(bool keep_normal = false) const; //void update_clipping_plane(bool keep_normal = false) const;
void set_common_data_ptr(CommonGizmosData* ptr) { m_c = ptr; } //void set_common_data_ptr(CommonGizmosData* ptr) { m_c = ptr; }
private: private:
bool on_init() override; bool on_init() override;
@ -92,7 +92,7 @@ private:
//void render_selection_rectangle() const; //void render_selection_rectangle() const;
void render_points(const Selection& selection, bool picking = false) const; void render_points(const Selection& selection, bool picking = false) const;
void render_clipping_plane(const Selection& selection) const; //void render_clipping_plane(const Selection& selection) const;
bool unsaved_changes() const; bool unsaved_changes() const;
bool m_lock_unique_islands = false; bool m_lock_unique_islands = false;
@ -104,6 +104,7 @@ private:
float m_density_stash = 0.f; // and again float m_density_stash = 0.f; // and again
mutable std::vector<CacheEntry> m_editing_cache; // a support point and whether it is currently selected mutable std::vector<CacheEntry> m_editing_cache; // a support point and whether it is currently selected
std::vector<sla::SupportPoint> m_normal_cache; // to restore after discarding changes or undo/redo std::vector<sla::SupportPoint> m_normal_cache; // to restore after discarding changes or undo/redo
const ModelObject* m_old_mo = nullptr;
//std::unique_ptr<ClippingPlane> m_clipping_plane; //std::unique_ptr<ClippingPlane> m_clipping_plane;
@ -117,7 +118,7 @@ private:
bool m_selection_empty = true; bool m_selection_empty = true;
EState m_old_state = Off; // to be able to see that the gizmo has just been closed (see on_set_state) EState m_old_state = Off; // to be able to see that the gizmo has just been closed (see on_set_state)
CommonGizmosData* m_c = nullptr; //CommonGizmosData* m_c = nullptr;
//mutable std::unique_ptr<MeshClipper> m_object_clipper; //mutable std::unique_ptr<MeshClipper> m_object_clipper;
//mutable std::unique_ptr<MeshClipper> m_supports_clipper; //mutable std::unique_ptr<MeshClipper> m_supports_clipper;
@ -159,6 +160,7 @@ protected:
std::string on_get_name() const override; std::string on_get_name() const override;
bool on_is_activable() const override; bool on_is_activable() const override;
bool on_is_selectable() const override; bool on_is_selectable() const override;
virtual CommonGizmosDataID on_get_requirements() const override;
void on_load(cereal::BinaryInputArchive& ar) override; void on_load(cereal::BinaryInputArchive& ar) override;
void on_save(cereal::BinaryOutputArchive& ar) const override; void on_save(cereal::BinaryOutputArchive& ar) const override;
}; };

View file

@ -196,16 +196,18 @@ void HollowedMesh::on_update()
size_t timestamp = print_object->step_state_with_timestamp(slaposDrillHoles).timestamp; size_t timestamp = print_object->step_state_with_timestamp(slaposDrillHoles).timestamp;
if (timestamp > m_old_hollowing_timestamp) { if (timestamp > m_old_hollowing_timestamp) {
const TriangleMesh& backend_mesh = print_object->get_mesh_to_print(); const TriangleMesh& backend_mesh = print_object->get_mesh_to_print();
m_hollowed_mesh_transformed.reset(new TriangleMesh(backend_mesh)); if (! backend_mesh.empty()) {
Transform3d trafo_inv = canvas->sla_print()->sla_trafo(*mo).inverse(); m_hollowed_mesh_transformed.reset(new TriangleMesh(backend_mesh));
m_hollowed_mesh_transformed->transform(trafo_inv); Transform3d trafo_inv = canvas->sla_print()->sla_trafo(*mo).inverse();
m_old_hollowing_timestamp = timestamp; m_hollowed_mesh_transformed->transform(trafo_inv);
m_old_hollowing_timestamp = timestamp;
}
else
m_hollowed_mesh_transformed.reset(nullptr);
} }
} }
else { else
m_hollowed_mesh_transformed.reset(nullptr); m_hollowed_mesh_transformed.reset(nullptr);
m_old_hollowing_timestamp = 0;
}
} }
} }
@ -417,7 +419,7 @@ void SupportsClipper::render_cut() const
const SelectionInfo* sel_info = get_pool()->selection_info(); const SelectionInfo* sel_info = get_pool()->selection_info();
const ModelObject* mo = sel_info->model_object(); const ModelObject* mo = sel_info->model_object();
Geometry::Transformation inst_trafo = mo->instances[sel_info->get_active_instance()]->get_transformation(); Geometry::Transformation inst_trafo = mo->instances[sel_info->get_active_instance()]->get_transformation();
Geometry::Transformation vol_trafo = mo->volumes.front()->get_transformation(); //Geometry::Transformation vol_trafo = mo->volumes.front()->get_transformation();
Geometry::Transformation trafo = inst_trafo;// * vol_trafo; Geometry::Transformation trafo = inst_trafo;// * vol_trafo;
trafo.set_offset(trafo.get_offset() + Vec3d(0., 0., sel_info->get_sla_shift())); trafo.set_offset(trafo.get_offset() + Vec3d(0., 0., sel_info->get_sla_shift()));

View file

@ -9,10 +9,10 @@
#include "slic3r/GUI/GUI_ObjectManipulation.hpp" #include "slic3r/GUI/GUI_ObjectManipulation.hpp"
#include "slic3r/GUI/PresetBundle.hpp" #include "slic3r/GUI/PresetBundle.hpp"
#include "slic3r/Utils/UndoRedo.hpp" #include "slic3r/Utils/UndoRedo.hpp"
#include "libslic3r/SLAPrint.hpp" //#include "libslic3r/SLAPrint.hpp"
#include "slic3r/GUI/MeshUtils.hpp" //#include "slic3r/GUI/MeshUtils.hpp"
#include "slic3r/GUI/Gizmos/GLGizmos.hpp" #include "slic3r/GUI/Gizmos/GLGizmos.hpp"
#include "slic3r/GUI/Camera.hpp" //#include "slic3r/GUI/Camera.hpp"
#include <wx/glcanvas.h> #include <wx/glcanvas.h>
@ -96,7 +96,7 @@ bool GLGizmosManager::init()
m_gizmos.emplace_back(new GLGizmoFlatten(m_parent, "place.svg", 3)); m_gizmos.emplace_back(new GLGizmoFlatten(m_parent, "place.svg", 3));
m_gizmos.emplace_back(new GLGizmoCut(m_parent, "cut.svg", 4)); m_gizmos.emplace_back(new GLGizmoCut(m_parent, "cut.svg", 4));
m_gizmos.emplace_back(new GLGizmoHollow(m_parent, "hollow.svg", 5)); m_gizmos.emplace_back(new GLGizmoHollow(m_parent, "hollow.svg", 5));
//m_gizmos.emplace_back(new GLGizmoSlaSupports(m_parent, "sla_supports.svg", 6)); m_gizmos.emplace_back(new GLGizmoSlaSupports(m_parent, "sla_supports.svg", 6));
//m_common_gizmos_data.reset(new CommonGizmosData()); //m_common_gizmos_data.reset(new CommonGizmosData());
//dynamic_cast<GLGizmoHollow*>(m_gizmos[Hollow].get())->set_common_data_ptr(m_common_gizmos_data.get()); //dynamic_cast<GLGizmoHollow*>(m_gizmos[Hollow].get())->set_common_data_ptr(m_common_gizmos_data.get());
@ -375,7 +375,9 @@ void GLGizmosManager::set_sla_support_data(ModelObject* model_object)
//gizmo_supports->set_sla_support_data(model_object, m_parent.get_selection()); //gizmo_supports->set_sla_support_data(model_object, m_parent.get_selection());
*/ */
auto* gizmo_hollow = dynamic_cast<GLGizmoHollow*>(m_gizmos[Hollow].get()); auto* gizmo_hollow = dynamic_cast<GLGizmoHollow*>(m_gizmos[Hollow].get());
auto* gizmo_supports = dynamic_cast<GLGizmoSlaSupports*>(m_gizmos[SlaSupports].get());
gizmo_hollow->set_sla_support_data(model_object, m_parent.get_selection()); gizmo_hollow->set_sla_support_data(model_object, m_parent.get_selection());
gizmo_supports->set_sla_support_data(model_object, m_parent.get_selection());
} }
// Returns true if the gizmo used the event to do something, false otherwise. // Returns true if the gizmo used the event to do something, false otherwise.
@ -1217,7 +1219,7 @@ bool GLGizmosManager::grabber_contains_mouse() const
} }
/*
CommonGizmosData::CommonGizmosData() CommonGizmosData::CommonGizmosData()
{ {
m_clipping_plane.reset(new ClippingPlane(Vec3d::Zero(), 0.)); m_clipping_plane.reset(new ClippingPlane(Vec3d::Zero(), 0.));
@ -1344,7 +1346,7 @@ void CommonGizmosData::build_AABB_if_needed()
m_supports_clipper.reset(); m_supports_clipper.reset();
m_old_mesh = m_mesh; m_old_mesh = m_mesh;
m_schedule_aabb_calculation = false; m_schedule_aabb_calculation = false;
} }*/
} // namespace GUI } // namespace GUI

View file

@ -3,7 +3,7 @@
#include "slic3r/GUI/GLTexture.hpp" #include "slic3r/GUI/GLTexture.hpp"
#include "slic3r/GUI/GLToolbar.hpp" #include "slic3r/GUI/GLToolbar.hpp"
#include "libslic3r/ObjectID.hpp" //#include "libslic3r/ObjectID.hpp"
#include "slic3r/GUI/Gizmos/GLGizmoBase.hpp" #include "slic3r/GUI/Gizmos/GLGizmoBase.hpp"
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp" #include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
@ -20,7 +20,7 @@ namespace GUI {
class GLCanvas3D; class GLCanvas3D;
class ClippingPlane; class ClippingPlane;
enum class SLAGizmoEventType : unsigned char; enum class SLAGizmoEventType : unsigned char;
class CommonGizmosData; //class CommonGizmosData;
class CommonGizmosDataPool; class CommonGizmosDataPool;
class Rect class Rect
@ -234,13 +234,13 @@ private:
class MeshRaycaster; //class MeshRaycaster;
class MeshClipper; //class MeshClipper;
// This class is only for sharing SLA related data between SLA gizmos // This class is only for sharing SLA related data between SLA gizmos
// and its synchronization with backend data. It should not be misused // and its synchronization with backend data. It should not be misused
// for anything else. // for anything else.
class CommonGizmosData { /*class CommonGizmosData {
public: public:
CommonGizmosData(); CommonGizmosData();
const TriangleMesh* mesh() const { const TriangleMesh* mesh() const {
@ -290,7 +290,7 @@ private:
bool m_has_drilled_mesh = false; bool m_has_drilled_mesh = false;
bool m_schedule_aabb_calculation = false; bool m_schedule_aabb_calculation = false;
}; };
*/
} // namespace GUI } // namespace GUI
} // namespace Slic3r } // namespace Slic3r