mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Merge branch 'master' of https://github.com/Prusa3d/Slic3r
This commit is contained in:
		
						commit
						5d96b02d6d
					
				
					 8 changed files with 186 additions and 22 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 29 KiB  | 
| 
						 | 
				
			
			@ -33,6 +33,8 @@
 | 
			
		|||
#define ENABLE_GIZMOS_SHORTCUT (1 && ENABLE_1_42_0)
 | 
			
		||||
// Scene's GUI made using imgui library
 | 
			
		||||
#define ENABLE_IMGUI (1 && ENABLE_1_42_0)
 | 
			
		||||
// Modified Sla support gizmo
 | 
			
		||||
#define ENABLE_SLA_SUPPORT_GIZMO_MOD (1 && ENABLE_1_42_0)
 | 
			
		||||
 | 
			
		||||
#endif // _technologies_h_
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2872,14 +2872,22 @@ void GLCanvas3D::Gizmos::set_flattening_data(const ModelObject* model_object)
 | 
			
		|||
        reinterpret_cast<GLGizmoFlatten*>(it->second)->set_flattening_data(model_object);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
void GLCanvas3D::Gizmos::set_sla_support_data(ModelObject* model_object, const GLCanvas3D::Selection& selection)
 | 
			
		||||
#else
 | 
			
		||||
void GLCanvas3D::Gizmos::set_model_object_ptr(ModelObject* model_object)
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
{
 | 
			
		||||
    if (!m_enabled)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    GizmosMap::const_iterator it = m_gizmos.find(SlaSupports);
 | 
			
		||||
    if (it != m_gizmos.end())
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
        reinterpret_cast<GLGizmoSlaSupports*>(it->second)->set_sla_support_data(model_object, selection);
 | 
			
		||||
#else
 | 
			
		||||
        reinterpret_cast<GLGizmoSlaSupports*>(it->second)->set_model_object_ptr(model_object);
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GLCanvas3D::Gizmos::clicked_on_object(const Vec2d& mouse_position)
 | 
			
		||||
| 
						 | 
				
			
			@ -5248,6 +5256,12 @@ void GLCanvas3D::set_camera_zoom(float zoom)
 | 
			
		|||
    _refresh_if_shown_on_screen();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GLCanvas3D::update_gizmos_on_off_state()
 | 
			
		||||
{
 | 
			
		||||
    set_as_dirty();
 | 
			
		||||
    m_gizmos.update_on_off_state(get_selection());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool GLCanvas3D::_is_shown_on_screen() const
 | 
			
		||||
{
 | 
			
		||||
    return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false;
 | 
			
		||||
| 
						 | 
				
			
			@ -6143,7 +6157,11 @@ void GLCanvas3D::_update_gizmos_data()
 | 
			
		|||
#endif // ENABLE_WORLD_ROTATIONS
 | 
			
		||||
        ModelObject* model_object = m_model->objects[m_selection.get_object_idx()];
 | 
			
		||||
        m_gizmos.set_flattening_data(model_object);
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
        m_gizmos.set_sla_support_data(model_object, m_selection);
 | 
			
		||||
#else
 | 
			
		||||
        m_gizmos.set_model_object_ptr(model_object);
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
#else
 | 
			
		||||
        ModelObject* model_object = m_model->objects[m_selection.get_object_idx()];
 | 
			
		||||
        ModelInstance* model_instance = model_object->instances[m_selection.get_instance_idx()];
 | 
			
		||||
| 
						 | 
				
			
			@ -6154,7 +6172,11 @@ void GLCanvas3D::_update_gizmos_data()
 | 
			
		|||
        m_gizmos.set_rotation(model_instance->get_rotation());
 | 
			
		||||
#endif // ENABLE_WORLD_ROTATIONS
 | 
			
		||||
        m_gizmos.set_flattening_data(model_object);
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
        m_gizmos.set_sla_support_data(model_object, m_selection);
 | 
			
		||||
#else
 | 
			
		||||
        m_gizmos.set_model_object_ptr(model_object);
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
 | 
			
		||||
    }
 | 
			
		||||
#if ENABLE_MODELVOLUME_TRANSFORM
 | 
			
		||||
| 
						 | 
				
			
			@ -6168,7 +6190,11 @@ void GLCanvas3D::_update_gizmos_data()
 | 
			
		|||
        m_gizmos.set_rotation(volume->get_volume_rotation());
 | 
			
		||||
#endif // ENABLE_WORLD_ROTATIONS
 | 
			
		||||
        m_gizmos.set_flattening_data(nullptr);
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
        m_gizmos.set_sla_support_data(nullptr, m_selection);
 | 
			
		||||
#else
 | 
			
		||||
        m_gizmos.set_model_object_ptr(nullptr);
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    }
 | 
			
		||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
 | 
			
		||||
    else
 | 
			
		||||
| 
						 | 
				
			
			@ -6176,7 +6202,11 @@ void GLCanvas3D::_update_gizmos_data()
 | 
			
		|||
        m_gizmos.set_scale(Vec3d::Ones());
 | 
			
		||||
        m_gizmos.set_rotation(Vec3d::Zero());
 | 
			
		||||
        m_gizmos.set_flattening_data(m_selection.is_from_single_object() ? m_model->objects[m_selection.get_object_idx()] : nullptr);
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
        m_gizmos.set_sla_support_data(nullptr, m_selection);
 | 
			
		||||
#else
 | 
			
		||||
        m_gizmos.set_model_object_ptr(nullptr);
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -652,7 +652,11 @@ private:
 | 
			
		|||
 | 
			
		||||
        void set_flattening_data(const ModelObject* model_object);
 | 
			
		||||
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
        void set_sla_support_data(ModelObject* model_object, const GLCanvas3D::Selection& selection);
 | 
			
		||||
#else
 | 
			
		||||
        void set_model_object_ptr(ModelObject* model_object);
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
        void clicked_on_object(const Vec2d& mouse_position);
 | 
			
		||||
        void delete_current_grabber(bool delete_all = false);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -919,6 +923,8 @@ public:
 | 
			
		|||
 | 
			
		||||
    void set_camera_zoom(float zoom);
 | 
			
		||||
 | 
			
		||||
    void update_gizmos_on_off_state();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    bool _is_shown_on_screen() const;
 | 
			
		||||
    void _force_zoom_to_bed();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1182,20 +1182,6 @@ GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent)
 | 
			
		|||
        ::gluQuadricDrawStyle(m_quadric, GLU_FILL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
GLGizmoMove3D::GLGizmoMove3D(const GLGizmoMove3D& other)
 | 
			
		||||
    : GLGizmoBase(other.m_parent)
 | 
			
		||||
    , m_displacement(other.m_displacement)
 | 
			
		||||
    , m_snap_step(other.m_snap_step)
 | 
			
		||||
    , m_starting_drag_position(other.m_starting_drag_position)
 | 
			
		||||
    , m_starting_box_center(other.m_starting_box_center)
 | 
			
		||||
    , m_starting_box_bottom_center(other.m_starting_box_bottom_center)
 | 
			
		||||
    , m_quadric(nullptr)
 | 
			
		||||
{
 | 
			
		||||
    m_quadric = ::gluNewQuadric();
 | 
			
		||||
    if (m_quadric != nullptr)
 | 
			
		||||
        ::gluQuadricDrawStyle(m_quadric, GLU_FILL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
GLGizmoMove3D::~GLGizmoMove3D()
 | 
			
		||||
{
 | 
			
		||||
    if (m_quadric != nullptr)
 | 
			
		||||
| 
						 | 
				
			
			@ -1757,10 +1743,27 @@ Vec3d GLGizmoFlatten::get_flattening_normal() const
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
GLGizmoSlaSupports::GLGizmoSlaSupports(GLCanvas3D& parent)
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    : GLGizmoBase(parent), m_starting_center(Vec3d::Zero()), m_quadric(nullptr)
 | 
			
		||||
#else
 | 
			
		||||
    : GLGizmoBase(parent), m_starting_center(Vec3d::Zero())
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
{
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    m_quadric = ::gluNewQuadric();
 | 
			
		||||
    if (m_quadric != nullptr)
 | 
			
		||||
        ::gluQuadricDrawStyle(m_quadric, GLU_FILL);
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
GLGizmoSlaSupports::~GLGizmoSlaSupports()
 | 
			
		||||
{
 | 
			
		||||
    if (m_quadric != nullptr)
 | 
			
		||||
        ::gluDeleteQuadric(m_quadric);
 | 
			
		||||
}
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
 | 
			
		||||
bool GLGizmoSlaSupports::on_init()
 | 
			
		||||
{
 | 
			
		||||
    std::string path = resources_dir() + "/icons/overlay/";
 | 
			
		||||
| 
						 | 
				
			
			@ -1781,6 +1784,20 @@ bool GLGizmoSlaSupports::on_init()
 | 
			
		|||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const GLCanvas3D::Selection& selection)
 | 
			
		||||
{
 | 
			
		||||
    m_starting_center = Vec3d::Zero();
 | 
			
		||||
    m_old_model_object = m_model_object;
 | 
			
		||||
    m_model_object = model_object;
 | 
			
		||||
 | 
			
		||||
    if ((model_object != nullptr) && selection.is_from_single_instance())
 | 
			
		||||
    {
 | 
			
		||||
        if (is_mesh_update_necessary())
 | 
			
		||||
            update_mesh();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
void GLGizmoSlaSupports::set_model_object_ptr(ModelObject* model_object)
 | 
			
		||||
{
 | 
			
		||||
    if (model_object != nullptr)
 | 
			
		||||
| 
						 | 
				
			
			@ -1796,12 +1813,14 @@ void GLGizmoSlaSupports::set_model_object_ptr(ModelObject* model_object)
 | 
			
		|||
            update_mesh();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
 | 
			
		||||
void GLGizmoSlaSupports::on_render(const GLCanvas3D::Selection& selection) const
 | 
			
		||||
{
 | 
			
		||||
    ::glEnable(GL_BLEND);
 | 
			
		||||
    ::glEnable(GL_DEPTH_TEST);
 | 
			
		||||
 | 
			
		||||
#if !ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    // the dragged_offset is a vector measuring where was the object moved
 | 
			
		||||
    // with the gizmo being on. This is reset in set_model_object_ptr and
 | 
			
		||||
    // does not work correctly when there are multiple copies.
 | 
			
		||||
| 
						 | 
				
			
			@ -1809,6 +1828,7 @@ void GLGizmoSlaSupports::on_render(const GLCanvas3D::Selection& selection) const
 | 
			
		|||
    if (m_starting_center == Vec3d::Zero())
 | 
			
		||||
        m_starting_center = selection.get_bounding_box().center();
 | 
			
		||||
    Vec3d dragged_offset = selection.get_bounding_box().center() - m_starting_center;
 | 
			
		||||
#endif // !ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
 | 
			
		||||
    for (auto& g : m_grabbers) {
 | 
			
		||||
        g.color[0] = 1.f;
 | 
			
		||||
| 
						 | 
				
			
			@ -1816,8 +1836,12 @@ void GLGizmoSlaSupports::on_render(const GLCanvas3D::Selection& selection) const
 | 
			
		|||
        g.color[2] = 0.f;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    render_grabbers(selection, false);
 | 
			
		||||
#else
 | 
			
		||||
    //::glTranslatef((GLfloat)dragged_offset(0), (GLfloat)dragged_offset(1), (GLfloat)dragged_offset(2));
 | 
			
		||||
    render_grabbers(false);
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
 | 
			
		||||
#if !ENABLE_IMGUI
 | 
			
		||||
    render_tooltip_texture();
 | 
			
		||||
| 
						 | 
				
			
			@ -1834,9 +1858,59 @@ void GLGizmoSlaSupports::on_render_for_picking(const GLCanvas3D::Selection& sele
 | 
			
		|||
        m_grabbers[i].color[1] = 1.0f;
 | 
			
		||||
        m_grabbers[i].color[2] = picking_color_component(i);
 | 
			
		||||
    }
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    render_grabbers(selection, true);
 | 
			
		||||
#else
 | 
			
		||||
    render_grabbers(true);
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
void GLGizmoSlaSupports::render_grabbers(const GLCanvas3D::Selection& selection, bool picking) const
 | 
			
		||||
{
 | 
			
		||||
    if (m_quadric == nullptr)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    if (!selection.is_from_single_instance())
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    const GLVolume* v = selection.get_volume(*selection.get_volume_idxs().begin());
 | 
			
		||||
    double z_shift = v->get_sla_shift_z();
 | 
			
		||||
 | 
			
		||||
    ::glPushMatrix();
 | 
			
		||||
    ::glTranslated(0.0, 0.0, z_shift);
 | 
			
		||||
 | 
			
		||||
    const Transform3d& m = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix();
 | 
			
		||||
    ::glMultMatrixd(m.data());
 | 
			
		||||
 | 
			
		||||
    if (!picking)
 | 
			
		||||
        ::glEnable(GL_LIGHTING);
 | 
			
		||||
 | 
			
		||||
    float render_color[3];
 | 
			
		||||
    for (int i = 0; i < (int)m_grabbers.size(); ++i)
 | 
			
		||||
    {
 | 
			
		||||
        if (!picking && (m_hover_id == i))
 | 
			
		||||
        {
 | 
			
		||||
            render_color[0] = 1.0f - m_grabbers[i].color[0];
 | 
			
		||||
            render_color[1] = 1.0f - m_grabbers[i].color[1];
 | 
			
		||||
            render_color[2] = 1.0f - m_grabbers[i].color[2];
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
            ::memcpy((void*)render_color, (const void*)m_grabbers[i].color, 3 * sizeof(float));
 | 
			
		||||
 | 
			
		||||
        ::glColor3fv(render_color);
 | 
			
		||||
        ::glPushMatrix();
 | 
			
		||||
        ::glTranslated(m_grabbers[i].center(0), m_grabbers[i].center(1), m_grabbers[i].center(2));
 | 
			
		||||
        ::gluSphere(m_quadric, 0.75, 36, 18);
 | 
			
		||||
        ::glPopMatrix();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!picking)
 | 
			
		||||
        ::glDisable(GL_LIGHTING);
 | 
			
		||||
 | 
			
		||||
    ::glPopMatrix();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
void GLGizmoSlaSupports::render_grabbers(bool picking) const
 | 
			
		||||
{
 | 
			
		||||
	if (m_parent.get_selection().is_empty())
 | 
			
		||||
| 
						 | 
				
			
			@ -1886,10 +1960,15 @@ void GLGizmoSlaSupports::render_grabbers(bool picking) const
 | 
			
		|||
 | 
			
		||||
    ::glTranslatef((GLfloat)0, (GLfloat)0, (GLfloat)-z_shift);
 | 
			
		||||
}
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
 | 
			
		||||
bool GLGizmoSlaSupports::is_mesh_update_necessary() const
 | 
			
		||||
{
 | 
			
		||||
    return m_state == On && m_model_object && ! m_model_object->instances.empty() && ! m_instance_matrix.isApprox(m_source_data.matrix);
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    return (m_state == On) && (m_model_object != nullptr) && (m_model_object != m_old_model_object) && !m_model_object->instances.empty();
 | 
			
		||||
#else
 | 
			
		||||
    return m_state == On && m_model_object && !m_model_object->instances.empty() && !m_instance_matrix.isApprox(m_source_data.matrix);
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
 | 
			
		||||
    //if (m_state != On || !m_model_object || m_model_object->instances.empty() || ! m_instance_matrix.isApprox(m_source_data.matrix))
 | 
			
		||||
    //    return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -1924,7 +2003,9 @@ void GLGizmoSlaSupports::update_mesh()
 | 
			
		|||
    m_AABB = igl::AABB<Eigen::MatrixXf,3>();
 | 
			
		||||
    m_AABB.init(m_V, m_F);
 | 
			
		||||
 | 
			
		||||
#if !ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    m_source_data.matrix = m_instance_matrix;
 | 
			
		||||
#endif // !ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
 | 
			
		||||
    // we'll now reload Grabbers (selection might have changed):
 | 
			
		||||
    m_grabbers.clear();
 | 
			
		||||
| 
						 | 
				
			
			@ -1937,7 +2018,11 @@ void GLGizmoSlaSupports::update_mesh()
 | 
			
		|||
Vec3f GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos)
 | 
			
		||||
{
 | 
			
		||||
    // if the gizmo doesn't have the V, F structures for igl, calculate them first:
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    if (m_V.size() == 0)
 | 
			
		||||
#else
 | 
			
		||||
    if (m_V.size() == 0 || is_mesh_update_necessary())
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
        update_mesh();
 | 
			
		||||
 | 
			
		||||
    Eigen::Matrix<GLint, 4, 1, Eigen::DontAlign> viewport;
 | 
			
		||||
| 
						 | 
				
			
			@ -1954,10 +2039,20 @@ Vec3f GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos)
 | 
			
		|||
 | 
			
		||||
    igl::Hit hit;
 | 
			
		||||
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    const GLCanvas3D::Selection& selection = m_parent.get_selection();
 | 
			
		||||
    const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
 | 
			
		||||
    double z_offset = volume->get_sla_shift_z();
 | 
			
		||||
#else
 | 
			
		||||
    double z_offset = m_parent.get_selection().get_volume(0)->get_sla_shift_z();
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    point1(2) -= z_offset;
 | 
			
		||||
	point2(2) -= z_offset;
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    Transform3d inv = volume->get_instance_transformation().get_matrix().inverse();
 | 
			
		||||
#else
 | 
			
		||||
    Transform3d inv = m_instance_matrix.inverse();
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    point1 = inv * point1;
 | 
			
		||||
    point2 = inv * point2;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1971,6 +2066,17 @@ Vec3f GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos)
 | 
			
		|||
 | 
			
		||||
void GLGizmoSlaSupports::clicked_on_object(const Vec2d& mouse_position)
 | 
			
		||||
{
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    int instance_id = m_parent.get_selection().get_instance_idx();
 | 
			
		||||
    if (m_old_instance_id != instance_id)
 | 
			
		||||
    {
 | 
			
		||||
        m_old_instance_id = instance_id;
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    if (instance_id == -1)
 | 
			
		||||
        return;
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
 | 
			
		||||
    Vec3f new_pos;
 | 
			
		||||
    try {
 | 
			
		||||
        new_pos = unproject_on_mesh(mouse_position); // this can throw - we don't want to create a new grabber in that case
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -365,7 +365,6 @@ class GLGizmoMove3D : public GLGizmoBase
 | 
			
		|||
 | 
			
		||||
public:
 | 
			
		||||
    explicit GLGizmoMove3D(GLCanvas3D& parent);
 | 
			
		||||
    GLGizmoMove3D(const GLGizmoMove3D& other);
 | 
			
		||||
    virtual ~GLGizmoMove3D();
 | 
			
		||||
 | 
			
		||||
    double get_snap_step(double step) const { return m_snap_step; }
 | 
			
		||||
| 
						 | 
				
			
			@ -440,16 +439,27 @@ class GLGizmoSlaSupports : public GLGizmoBase
 | 
			
		|||
{
 | 
			
		||||
private:
 | 
			
		||||
    ModelObject* m_model_object = nullptr;
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    ModelObject* m_old_model_object = nullptr;
 | 
			
		||||
    int m_old_instance_id = -1;
 | 
			
		||||
#else
 | 
			
		||||
    Transform3d m_instance_matrix;
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    Vec3f unproject_on_mesh(const Vec2d& mouse_pos);
 | 
			
		||||
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    GLUquadricObj* m_quadric;
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
 | 
			
		||||
    Eigen::MatrixXf m_V; // vertices
 | 
			
		||||
    Eigen::MatrixXi m_F; // facets indices
 | 
			
		||||
    igl::AABB<Eigen::MatrixXf,3> m_AABB;
 | 
			
		||||
 | 
			
		||||
    struct SourceDataSummary {
 | 
			
		||||
#if !ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
        BoundingBoxf3 bounding_box;
 | 
			
		||||
        Transform3d matrix;
 | 
			
		||||
#endif // !ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
        Vec3d mesh_first_point;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -460,7 +470,12 @@ private:
 | 
			
		|||
 | 
			
		||||
public:
 | 
			
		||||
    explicit GLGizmoSlaSupports(GLCanvas3D& parent);
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    virtual ~GLGizmoSlaSupports();
 | 
			
		||||
    void set_sla_support_data(ModelObject* model_object, const GLCanvas3D::Selection& selection);
 | 
			
		||||
#else
 | 
			
		||||
    void set_model_object_ptr(ModelObject* model_object);
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    void clicked_on_object(const Vec2d& mouse_position);
 | 
			
		||||
    void delete_current_grabber(bool delete_all);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -470,7 +485,11 @@ private:
 | 
			
		|||
    virtual void on_render(const GLCanvas3D::Selection& selection) const;
 | 
			
		||||
    virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
 | 
			
		||||
 | 
			
		||||
#if ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    void render_grabbers(const GLCanvas3D::Selection& selection, bool picking = false) const;
 | 
			
		||||
#else
 | 
			
		||||
    void render_grabbers(bool picking = false) const;
 | 
			
		||||
#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD
 | 
			
		||||
    bool is_mesh_update_necessary() const;
 | 
			
		||||
    void update_mesh();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1405,7 +1405,7 @@ void ObjectList::update_selections_on_canvas()
 | 
			
		|||
    const int sel_cnt = GetSelectedItemsCount();
 | 
			
		||||
    if (sel_cnt == 0) {
 | 
			
		||||
        selection.clear();
 | 
			
		||||
        wxGetApp().plater()->canvas3D()->set_as_dirty();
 | 
			
		||||
        wxGetApp().plater()->canvas3D()->update_gizmos_on_off_state();
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1435,7 +1435,7 @@ void ObjectList::update_selections_on_canvas()
 | 
			
		|||
        else
 | 
			
		||||
            add_to_selection(item, selection, true);
 | 
			
		||||
            
 | 
			
		||||
        wxGetApp().plater()->canvas3D()->set_as_dirty();
 | 
			
		||||
        wxGetApp().plater()->canvas3D()->update_gizmos_on_off_state();
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
| 
						 | 
				
			
			@ -1446,7 +1446,7 @@ void ObjectList::update_selections_on_canvas()
 | 
			
		|||
    for (auto item: sels)
 | 
			
		||||
        add_to_selection(item, selection, false);
 | 
			
		||||
 | 
			
		||||
    wxGetApp().plater()->canvas3D()->set_as_dirty();
 | 
			
		||||
    wxGetApp().plater()->canvas3D()->update_gizmos_on_off_state();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ObjectList::select_item(const wxDataViewItem& item)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1563,6 +1563,7 @@ void Plater::priv::object_list_changed()
 | 
			
		|||
void Plater::priv::select_all()
 | 
			
		||||
{
 | 
			
		||||
    this->canvas3D->select_all();
 | 
			
		||||
    this->sidebar->obj_list()->update_selections();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Plater::priv::remove(size_t obj_idx)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue