
740067c
: "Fixed cut contours in gizmo cut after deleting an object"e645f4a
: "Fixed cut contours after cutting an object in gizmo cut"
76 lines
2.3 KiB
C++
76 lines
2.3 KiB
C++
#ifndef slic3r_GLGizmoCut_hpp_
|
|
#define slic3r_GLGizmoCut_hpp_
|
|
|
|
#include "GLGizmoBase.hpp"
|
|
#if ENABLE_SINKING_CONTOURS
|
|
#include "slic3r/GUI/GLModel.hpp"
|
|
#include "libslic3r/TriangleMesh.hpp"
|
|
#endif // ENABLE_SINKING_CONTOURS
|
|
|
|
namespace Slic3r {
|
|
namespace GUI {
|
|
|
|
class GLGizmoCut : public GLGizmoBase
|
|
{
|
|
static const double Offset;
|
|
static const double Margin;
|
|
static const std::array<float, 4> GrabberColor;
|
|
|
|
double m_cut_z{ 0.0 };
|
|
double m_max_z{ 0.0 };
|
|
double m_start_z{ 0.0 };
|
|
Vec3d m_drag_pos;
|
|
Vec3d m_drag_center;
|
|
bool m_keep_upper{ true };
|
|
bool m_keep_lower{ true };
|
|
bool m_rotate_lower{ false };
|
|
|
|
#if ENABLE_SINKING_CONTOURS
|
|
struct CutContours
|
|
{
|
|
TriangleMesh mesh;
|
|
GLModel contours;
|
|
double cut_z{ 0.0 };
|
|
Vec3d position{ Vec3d::Zero() };
|
|
Vec3d shift{ Vec3d::Zero() };
|
|
int object_idx{ -1 };
|
|
int instance_idx{ -1 };
|
|
};
|
|
|
|
CutContours m_cut_contours;
|
|
#endif // ENABLE_SINKING_CONTOURS
|
|
|
|
public:
|
|
GLGizmoCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
|
|
|
double get_cut_z() const { return m_cut_z; }
|
|
void set_cut_z(double cut_z);
|
|
|
|
std::string get_tooltip() const override;
|
|
|
|
protected:
|
|
virtual bool on_init() override;
|
|
virtual void on_load(cereal::BinaryInputArchive& ar) override { ar(m_cut_z, m_keep_upper, m_keep_lower, m_rotate_lower); }
|
|
virtual void on_save(cereal::BinaryOutputArchive& ar) const override { ar(m_cut_z, m_keep_upper, m_keep_lower, m_rotate_lower); }
|
|
virtual std::string on_get_name() const override;
|
|
virtual void on_set_state() override;
|
|
virtual bool on_is_activable() const override;
|
|
virtual void on_start_dragging() override;
|
|
virtual void on_update(const UpdateData& data) override;
|
|
virtual void on_render() override;
|
|
virtual void on_render_for_picking() override;
|
|
virtual void on_render_input_window(float x, float y, float bottom_limit) override;
|
|
|
|
private:
|
|
void perform_cut(const Selection& selection);
|
|
double calc_projection(const Linef3& mouse_ray) const;
|
|
BoundingBoxf3 bounding_box() const;
|
|
#if ENABLE_SINKING_CONTOURS
|
|
void update_contours();
|
|
#endif // ENABLE_SINKING_CONTOURS
|
|
};
|
|
|
|
} // namespace GUI
|
|
} // namespace Slic3r
|
|
|
|
#endif // slic3r_GLGizmoCut_hpp_
|