mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 07:22:03 +08:00
87 lines
2.6 KiB
C++
87 lines
2.6 KiB
C++
#ifndef slic3r_GLGizmoCut_hpp_
|
|
#define slic3r_GLGizmoCut_hpp_
|
|
|
|
#include "GLGizmoBase.hpp"
|
|
#include "slic3r/GUI/GLModel.hpp"
|
|
#include "libslic3r/TriangleMesh.hpp"
|
|
#include "libslic3r/ObjectID.hpp"
|
|
|
|
namespace Slic3r {
|
|
namespace GUI {
|
|
class Selection;
|
|
|
|
class GLGizmoCut : public GLGizmoBase
|
|
{
|
|
static const double Offset;
|
|
static const double Margin;
|
|
|
|
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_LEGACY_OPENGL_REMOVAL
|
|
GLModel m_plane;
|
|
GLModel m_grabber_connection;
|
|
Vec3d m_old_center;
|
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
|
|
|
struct CutContours
|
|
{
|
|
TriangleMesh mesh;
|
|
GLModel contours;
|
|
double cut_z{ 0.0 };
|
|
Vec3d position{ Vec3d::Zero() };
|
|
Vec3d shift{ Vec3d::Zero() };
|
|
ObjectID object_id;
|
|
int instance_idx{ -1 };
|
|
std::vector<ObjectID> volumes_idxs;
|
|
};
|
|
|
|
CutContours m_cut_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;
|
|
|
|
/// <summary>
|
|
/// Drag of plane
|
|
/// </summary>
|
|
/// <param name="mouse_event">Keep information about mouse click</param>
|
|
/// <returns>Return True when use the information otherwise False.</returns>
|
|
bool on_mouse(const wxMouseEvent &mouse_event) 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_dragging(const UpdateData& data) override;
|
|
virtual void on_render() override;
|
|
#if !ENABLE_RAYCAST_PICKING
|
|
virtual void on_render_for_picking() override;
|
|
#endif // !ENABLE_RAYCAST_PICKING
|
|
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;
|
|
void update_contours();
|
|
};
|
|
|
|
} // namespace GUI
|
|
} // namespace Slic3r
|
|
|
|
#endif // slic3r_GLGizmoCut_hpp_
|