#ifndef slic3r_GLGizmoFlatten_hpp_ #define slic3r_GLGizmoFlatten_hpp_ #include "GLGizmoBase.hpp" namespace Slic3r { namespace GUI { class GLGizmoFlatten : public GLGizmoBase { // This gizmo does not use grabbers. The m_hover_id relates to polygon managed by the class itself. private: mutable Vec3d m_normal; struct PlaneData { std::vector vertices; Vec3d normal; float area; }; // This holds information to decide whether recalculation is necessary: std::vector m_volumes_matrices; std::vector m_volumes_types; Vec3d m_first_instance_scale; Vec3d m_first_instance_mirror; std::vector m_planes; bool m_planes_valid = false; mutable Vec3d m_starting_center; const ModelObject* m_model_object = nullptr; std::vector instances_matrices; void update_planes(); bool is_plane_update_necessary() const; public: #if ENABLE_SVG_ICONS GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); #else GLGizmoFlatten(GLCanvas3D& parent, unsigned int sprite_id); #endif // ENABLE_SVG_ICONS void set_flattening_data(const ModelObject* model_object); Vec3d get_flattening_normal() const; protected: virtual bool on_init(); virtual std::string on_get_name() const; virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const; virtual void on_start_dragging(const GLCanvas3D::Selection& selection); virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection) {} virtual void on_render(const GLCanvas3D::Selection& selection) const; virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const; virtual void on_set_state() { if (m_state == On && is_plane_update_necessary()) update_planes(); } }; } // namespace GUI } // namespace Slic3r #endif // slic3r_GLGizmoFlatten_hpp_