2018-06-13 07:12:16 +00:00
|
|
|
#ifndef slic3r_GLGizmo_hpp_
|
|
|
|
#define slic3r_GLGizmo_hpp_
|
|
|
|
|
2018-11-26 09:49:25 +00:00
|
|
|
#include <igl/AABB.h>
|
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
#include "../../slic3r/GUI/GLTexture.hpp"
|
2018-10-15 09:30:50 +00:00
|
|
|
#include "../../slic3r/GUI/GLCanvas3D.hpp"
|
2018-12-07 13:10:16 +00:00
|
|
|
|
2018-12-06 11:52:28 +00:00
|
|
|
#include "libslic3r/Point.hpp"
|
|
|
|
#include "libslic3r/BoundingBox.hpp"
|
2018-12-07 13:10:16 +00:00
|
|
|
#include "libslic3r/SLA/SLAAutoSupports.hpp"
|
2018-06-15 12:10:28 +00:00
|
|
|
|
2018-10-18 13:13:38 +00:00
|
|
|
#include <array>
|
2018-06-15 12:10:28 +00:00
|
|
|
#include <vector>
|
2018-10-18 13:13:38 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
|
|
class wxWindow;
|
2018-12-03 08:37:46 +00:00
|
|
|
class GLUquadric;
|
|
|
|
typedef class GLUquadric GLUquadricObj;
|
2018-10-18 13:13:38 +00:00
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
2018-06-13 13:44:04 +00:00
|
|
|
|
|
|
|
class BoundingBoxf3;
|
2018-08-20 08:23:17 +00:00
|
|
|
class Linef3;
|
2018-08-17 13:40:47 +00:00
|
|
|
class ModelObject;
|
2018-06-13 13:44:04 +00:00
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2018-08-24 12:11:41 +00:00
|
|
|
class GLCanvas3D;
|
2018-11-27 11:00:44 +00:00
|
|
|
#if ENABLE_IMGUI
|
2018-11-26 09:56:07 +00:00
|
|
|
class ImGuiWrapper;
|
2018-11-27 11:00:44 +00:00
|
|
|
#endif // ENABLE_IMGUI
|
2018-08-24 12:11:41 +00:00
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
class GLGizmoBase
|
|
|
|
{
|
2018-06-14 08:00:59 +00:00
|
|
|
protected:
|
2018-06-15 12:10:28 +00:00
|
|
|
struct Grabber
|
|
|
|
{
|
2018-09-11 12:48:17 +00:00
|
|
|
static const float SizeFactor;
|
|
|
|
static const float MinHalfSize;
|
2018-08-20 08:23:17 +00:00
|
|
|
static const float DraggingScaleFactor;
|
2018-06-15 12:10:28 +00:00
|
|
|
|
2018-08-23 13:37:38 +00:00
|
|
|
Vec3d center;
|
2018-08-28 11:23:28 +00:00
|
|
|
Vec3d angles;
|
2018-06-15 12:10:28 +00:00
|
|
|
float color[3];
|
2018-09-11 10:40:42 +00:00
|
|
|
bool enabled;
|
2018-08-20 08:23:17 +00:00
|
|
|
bool dragging;
|
2018-06-15 12:10:28 +00:00
|
|
|
|
|
|
|
Grabber();
|
2018-08-20 08:23:17 +00:00
|
|
|
|
2018-10-12 14:18:37 +00:00
|
|
|
void render(bool hover, float size) const;
|
|
|
|
void render_for_picking(float size) const { render(size, color, false); }
|
2018-08-20 08:23:17 +00:00
|
|
|
|
2018-11-15 09:16:51 +00:00
|
|
|
float get_half_size(float size) const;
|
|
|
|
float get_dragging_half_size(float size) const;
|
|
|
|
|
2018-08-20 08:23:17 +00:00
|
|
|
private:
|
2018-10-12 14:18:37 +00:00
|
|
|
void render(float size, const float* render_color, bool use_lighting) const;
|
2018-08-21 12:27:36 +00:00
|
|
|
void render_face(float half_size) const;
|
2018-06-15 12:10:28 +00:00
|
|
|
};
|
2018-06-14 08:00:59 +00:00
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
public:
|
|
|
|
enum EState
|
|
|
|
{
|
|
|
|
Off,
|
|
|
|
Hover,
|
|
|
|
On,
|
|
|
|
Num_States
|
|
|
|
};
|
|
|
|
|
2018-11-14 11:57:12 +00:00
|
|
|
struct UpdateData
|
|
|
|
{
|
|
|
|
const Linef3 mouse_ray;
|
|
|
|
const Point* mouse_pos;
|
|
|
|
bool shift_down;
|
|
|
|
|
|
|
|
UpdateData(const Linef3& mouse_ray, const Point* mouse_pos = nullptr, bool shift_down = false)
|
|
|
|
: mouse_ray(mouse_ray), mouse_pos(mouse_pos), shift_down(shift_down)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
protected:
|
2018-08-24 12:11:41 +00:00
|
|
|
GLCanvas3D& m_parent;
|
|
|
|
|
2018-08-20 08:23:17 +00:00
|
|
|
int m_group_id;
|
2018-11-08 15:18:05 +00:00
|
|
|
EState m_state;
|
2018-11-22 09:14:31 +00:00
|
|
|
int m_shortcut_key;
|
2018-06-15 12:10:28 +00:00
|
|
|
// textures are assumed to be square and all with the same size in pixels, no internal check is done
|
2018-06-13 07:12:16 +00:00
|
|
|
GLTexture m_textures[Num_States];
|
2018-06-14 13:32:26 +00:00
|
|
|
int m_hover_id;
|
2018-09-10 08:01:49 +00:00
|
|
|
bool m_dragging;
|
2018-08-20 08:23:17 +00:00
|
|
|
float m_base_color[3];
|
|
|
|
float m_drag_color[3];
|
|
|
|
float m_highlight_color[3];
|
2018-06-15 12:10:28 +00:00
|
|
|
mutable std::vector<Grabber> m_grabbers;
|
2018-11-27 11:00:44 +00:00
|
|
|
#if ENABLE_IMGUI
|
2018-11-26 09:56:07 +00:00
|
|
|
ImGuiWrapper* m_imgui;
|
2018-11-27 11:00:44 +00:00
|
|
|
#endif // ENABLE_IMGUI
|
2018-06-13 07:12:16 +00:00
|
|
|
|
|
|
|
public:
|
2018-08-24 12:11:41 +00:00
|
|
|
explicit GLGizmoBase(GLCanvas3D& parent);
|
2018-08-20 08:23:17 +00:00
|
|
|
virtual ~GLGizmoBase() {}
|
|
|
|
|
|
|
|
bool init() { return on_init(); }
|
2018-06-13 07:12:16 +00:00
|
|
|
|
2018-10-25 07:35:08 +00:00
|
|
|
std::string get_name() const { return on_get_name(); }
|
|
|
|
|
2018-08-20 08:23:17 +00:00
|
|
|
int get_group_id() const { return m_group_id; }
|
|
|
|
void set_group_id(int id) { m_group_id = id; }
|
2018-06-13 07:12:16 +00:00
|
|
|
|
2018-08-20 08:23:17 +00:00
|
|
|
EState get_state() const { return m_state; }
|
2018-11-14 11:57:12 +00:00
|
|
|
void set_state(EState state) { m_state = state; on_set_state(); }
|
2018-06-13 07:12:16 +00:00
|
|
|
|
2018-11-22 09:14:31 +00:00
|
|
|
int get_shortcut_key() const { return m_shortcut_key; }
|
|
|
|
void set_shortcut_key(int key) { m_shortcut_key = key; }
|
|
|
|
|
2018-10-16 12:56:35 +00:00
|
|
|
bool is_activable(const GLCanvas3D::Selection& selection) const { return on_is_activable(selection); }
|
2018-11-19 13:46:37 +00:00
|
|
|
bool is_selectable() const { return on_is_selectable(); }
|
2018-10-08 12:02:12 +00:00
|
|
|
|
2018-08-21 06:50:35 +00:00
|
|
|
unsigned int get_texture_id() const { return m_textures[m_state].get_id(); }
|
|
|
|
int get_textures_size() const { return m_textures[Off].get_width(); }
|
2018-06-13 07:12:16 +00:00
|
|
|
|
2018-08-20 08:23:17 +00:00
|
|
|
int get_hover_id() const { return m_hover_id; }
|
2018-06-14 13:32:26 +00:00
|
|
|
void set_hover_id(int id);
|
2018-09-11 10:40:42 +00:00
|
|
|
|
2018-08-20 08:23:17 +00:00
|
|
|
void set_highlight_color(const float* color);
|
|
|
|
|
2018-09-11 10:40:42 +00:00
|
|
|
void enable_grabber(unsigned int id);
|
|
|
|
void disable_grabber(unsigned int id);
|
|
|
|
|
2018-10-15 09:30:50 +00:00
|
|
|
void start_dragging(const GLCanvas3D::Selection& selection);
|
2018-07-12 09:26:13 +00:00
|
|
|
void stop_dragging();
|
2018-09-10 08:01:49 +00:00
|
|
|
bool is_dragging() const { return m_dragging; }
|
|
|
|
|
2019-01-10 12:13:11 +00:00
|
|
|
void update(const UpdateData& data, const GLCanvas3D::Selection& selection);
|
2018-06-15 12:10:28 +00:00
|
|
|
|
2018-10-15 09:30:50 +00:00
|
|
|
void render(const GLCanvas3D::Selection& selection) const { on_render(selection); }
|
|
|
|
void render_for_picking(const GLCanvas3D::Selection& selection) const { on_render_for_picking(selection); }
|
2018-06-13 07:12:16 +00:00
|
|
|
|
2018-11-27 10:28:00 +00:00
|
|
|
#if !ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
virtual void create_external_gizmo_widgets(wxWindow *parent);
|
2018-11-26 09:56:07 +00:00
|
|
|
#endif // not ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
|
2018-10-31 09:19:44 +00:00
|
|
|
#if ENABLE_IMGUI
|
2018-11-26 09:56:07 +00:00
|
|
|
void render_input_window(float x, float y, const GLCanvas3D::Selection& selection) { on_render_input_window(x, y, selection); }
|
2018-10-31 09:19:44 +00:00
|
|
|
#endif // ENABLE_IMGUI
|
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
protected:
|
|
|
|
virtual bool on_init() = 0;
|
2018-10-25 07:35:08 +00:00
|
|
|
virtual std::string on_get_name() const = 0;
|
2018-08-20 08:23:17 +00:00
|
|
|
virtual void on_set_state() {}
|
|
|
|
virtual void on_set_hover_id() {}
|
2018-10-16 12:56:35 +00:00
|
|
|
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return true; }
|
2018-11-19 13:46:37 +00:00
|
|
|
virtual bool on_is_selectable() const { return true; }
|
2018-09-11 10:40:42 +00:00
|
|
|
virtual void on_enable_grabber(unsigned int id) {}
|
|
|
|
virtual void on_disable_grabber(unsigned int id) {}
|
2018-10-15 09:30:50 +00:00
|
|
|
virtual void on_start_dragging(const GLCanvas3D::Selection& selection) {}
|
2018-08-20 08:23:17 +00:00
|
|
|
virtual void on_stop_dragging() {}
|
2019-01-10 12:13:11 +00:00
|
|
|
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection) = 0;
|
2018-10-15 09:30:50 +00:00
|
|
|
virtual void on_render(const GLCanvas3D::Selection& selection) const = 0;
|
|
|
|
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const = 0;
|
2018-06-14 08:00:59 +00:00
|
|
|
|
2018-10-31 09:19:44 +00:00
|
|
|
#if ENABLE_IMGUI
|
2018-11-26 09:56:07 +00:00
|
|
|
virtual void on_render_input_window(float x, float y, const GLCanvas3D::Selection& selection) {}
|
2018-10-31 09:19:44 +00:00
|
|
|
#endif // ENABLE_IMGUI
|
|
|
|
|
2018-08-20 08:23:17 +00:00
|
|
|
float picking_color_component(unsigned int id) const;
|
2018-09-11 12:48:17 +00:00
|
|
|
void render_grabbers(const BoundingBoxf3& box) const;
|
2018-11-28 15:09:04 +00:00
|
|
|
void render_grabbers(float size) const;
|
2018-09-11 12:48:17 +00:00
|
|
|
void render_grabbers_for_picking(const BoundingBoxf3& box) const;
|
2018-08-24 12:11:41 +00:00
|
|
|
|
|
|
|
void set_tooltip(const std::string& tooltip) const;
|
|
|
|
std::string format(float value, unsigned int decimals) const;
|
2018-06-13 07:12:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class GLGizmoRotate : public GLGizmoBase
|
|
|
|
{
|
2018-06-14 08:00:59 +00:00
|
|
|
static const float Offset;
|
|
|
|
static const unsigned int CircleResolution;
|
2018-06-15 14:16:55 +00:00
|
|
|
static const unsigned int AngleResolution;
|
2018-06-14 08:00:59 +00:00
|
|
|
static const unsigned int ScaleStepsCount;
|
|
|
|
static const float ScaleStepRad;
|
|
|
|
static const unsigned int ScaleLongEvery;
|
|
|
|
static const float ScaleLongTooth;
|
|
|
|
static const unsigned int SnapRegionsCount;
|
|
|
|
static const float GrabberOffset;
|
|
|
|
|
2018-08-20 08:23:17 +00:00
|
|
|
public:
|
|
|
|
enum Axis : unsigned char
|
|
|
|
{
|
|
|
|
X,
|
|
|
|
Y,
|
|
|
|
Z
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
Axis m_axis;
|
2018-08-28 11:23:28 +00:00
|
|
|
double m_angle;
|
2018-06-13 07:12:16 +00:00
|
|
|
|
2018-12-03 08:37:46 +00:00
|
|
|
GLUquadricObj* m_quadric;
|
|
|
|
|
2018-08-23 13:37:38 +00:00
|
|
|
mutable Vec3d m_center;
|
2018-06-15 14:16:55 +00:00
|
|
|
mutable float m_radius;
|
|
|
|
|
2018-09-21 11:44:38 +00:00
|
|
|
mutable float m_snap_coarse_in_radius;
|
|
|
|
mutable float m_snap_coarse_out_radius;
|
|
|
|
mutable float m_snap_fine_in_radius;
|
|
|
|
mutable float m_snap_fine_out_radius;
|
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
public:
|
2018-08-24 12:11:41 +00:00
|
|
|
GLGizmoRotate(GLCanvas3D& parent, Axis axis);
|
2018-12-03 08:37:46 +00:00
|
|
|
GLGizmoRotate(const GLGizmoRotate& other);
|
|
|
|
virtual ~GLGizmoRotate();
|
2018-06-13 07:12:16 +00:00
|
|
|
|
2018-08-28 11:23:28 +00:00
|
|
|
double get_angle() const { return m_angle; }
|
|
|
|
void set_angle(double angle);
|
2018-06-19 07:46:26 +00:00
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
protected:
|
|
|
|
virtual bool on_init();
|
2018-10-25 07:35:08 +00:00
|
|
|
virtual std::string on_get_name() const { return ""; }
|
2018-10-15 09:30:50 +00:00
|
|
|
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
2019-01-10 12:13:11 +00:00
|
|
|
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection);
|
2018-10-15 09:30:50 +00:00
|
|
|
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
|
|
|
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
2018-06-14 08:00:59 +00:00
|
|
|
|
|
|
|
private:
|
2018-08-20 08:23:17 +00:00
|
|
|
void render_circle() const;
|
|
|
|
void render_scale() const;
|
|
|
|
void render_snap_radii() const;
|
|
|
|
void render_reference_radius() const;
|
|
|
|
void render_angle() const;
|
2018-09-11 12:48:17 +00:00
|
|
|
void render_grabber(const BoundingBoxf3& box) const;
|
2018-11-29 14:10:11 +00:00
|
|
|
void render_grabber_extension(const BoundingBoxf3& box, bool picking) const;
|
2018-08-20 08:23:17 +00:00
|
|
|
|
2019-01-10 12:13:11 +00:00
|
|
|
void transform_to_local(const GLCanvas3D::Selection& selection) const;
|
2018-08-23 13:37:38 +00:00
|
|
|
// returns the intersection of the mouse ray with the plane perpendicular to the gizmo axis, in local coordinate
|
2019-01-10 12:13:11 +00:00
|
|
|
Vec3d mouse_position_in_local_plane(const Linef3& mouse_ray, const GLCanvas3D::Selection& selection) const;
|
2018-08-20 08:23:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class GLGizmoRotate3D : public GLGizmoBase
|
|
|
|
{
|
2018-09-10 08:01:49 +00:00
|
|
|
std::vector<GLGizmoRotate> m_gizmos;
|
2018-08-20 08:23:17 +00:00
|
|
|
|
|
|
|
public:
|
2018-08-24 12:11:41 +00:00
|
|
|
explicit GLGizmoRotate3D(GLCanvas3D& parent);
|
2018-08-20 08:23:17 +00:00
|
|
|
|
2018-09-20 13:00:40 +00:00
|
|
|
Vec3d get_rotation() const { return Vec3d(m_gizmos[X].get_angle(), m_gizmos[Y].get_angle(), m_gizmos[Z].get_angle()); }
|
|
|
|
void set_rotation(const Vec3d& rotation) { m_gizmos[X].set_angle(rotation(0)); m_gizmos[Y].set_angle(rotation(1)); m_gizmos[Z].set_angle(rotation(2)); }
|
2018-08-20 08:23:17 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool on_init();
|
2018-10-25 07:35:08 +00:00
|
|
|
virtual std::string on_get_name() const;
|
2018-08-21 06:50:35 +00:00
|
|
|
virtual void on_set_state()
|
|
|
|
{
|
2018-09-10 08:01:49 +00:00
|
|
|
for (GLGizmoRotate& g : m_gizmos)
|
|
|
|
{
|
|
|
|
g.set_state(m_state);
|
|
|
|
}
|
2018-08-21 06:50:35 +00:00
|
|
|
}
|
|
|
|
virtual void on_set_hover_id()
|
|
|
|
{
|
2018-09-10 08:01:49 +00:00
|
|
|
for (unsigned int i = 0; i < 3; ++i)
|
|
|
|
{
|
|
|
|
m_gizmos[i].set_hover_id((m_hover_id == i) ? 0 : -1);
|
|
|
|
}
|
2018-08-21 06:50:35 +00:00
|
|
|
}
|
2018-10-16 12:56:35 +00:00
|
|
|
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return !selection.is_wipe_tower(); }
|
2018-09-11 10:40:42 +00:00
|
|
|
virtual void on_enable_grabber(unsigned int id)
|
|
|
|
{
|
|
|
|
if ((0 <= id) && (id < 3))
|
|
|
|
m_gizmos[id].enable_grabber(0);
|
|
|
|
}
|
|
|
|
virtual void on_disable_grabber(unsigned int id)
|
|
|
|
{
|
|
|
|
if ((0 <= id) && (id < 3))
|
|
|
|
m_gizmos[id].disable_grabber(0);
|
|
|
|
}
|
2018-10-15 09:30:50 +00:00
|
|
|
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
2018-08-20 08:23:17 +00:00
|
|
|
virtual void on_stop_dragging();
|
2019-01-10 12:13:11 +00:00
|
|
|
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection)
|
2018-08-21 06:50:35 +00:00
|
|
|
{
|
2018-09-10 08:01:49 +00:00
|
|
|
for (GLGizmoRotate& g : m_gizmos)
|
|
|
|
{
|
2019-01-10 12:13:11 +00:00
|
|
|
g.update(data, selection);
|
2018-09-10 08:01:49 +00:00
|
|
|
}
|
2018-08-21 06:50:35 +00:00
|
|
|
}
|
2018-10-15 09:30:50 +00:00
|
|
|
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
|
|
|
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
|
|
|
{
|
|
|
|
for (const GLGizmoRotate& g : m_gizmos)
|
|
|
|
{
|
|
|
|
g.render_for_picking(selection);
|
|
|
|
}
|
|
|
|
}
|
2018-10-31 09:19:44 +00:00
|
|
|
|
|
|
|
#if ENABLE_IMGUI
|
2018-11-26 09:56:07 +00:00
|
|
|
virtual void on_render_input_window(float x, float y, const GLCanvas3D::Selection& selection);
|
2018-10-31 09:19:44 +00:00
|
|
|
#endif // ENABLE_IMGUI
|
2018-06-13 07:12:16 +00:00
|
|
|
};
|
|
|
|
|
2018-08-21 06:50:35 +00:00
|
|
|
class GLGizmoScale3D : public GLGizmoBase
|
|
|
|
{
|
|
|
|
static const float Offset;
|
|
|
|
|
|
|
|
mutable BoundingBoxf3 m_box;
|
|
|
|
|
2018-08-28 11:23:28 +00:00
|
|
|
Vec3d m_scale;
|
2018-08-21 06:50:35 +00:00
|
|
|
|
2018-11-14 11:57:12 +00:00
|
|
|
double m_snap_step;
|
|
|
|
|
2018-08-28 11:23:28 +00:00
|
|
|
Vec3d m_starting_scale;
|
2018-08-23 13:37:38 +00:00
|
|
|
Vec3d m_starting_drag_position;
|
2018-08-29 11:36:03 +00:00
|
|
|
BoundingBoxf3 m_starting_box;
|
2018-08-21 06:50:35 +00:00
|
|
|
|
|
|
|
public:
|
2018-08-24 12:11:41 +00:00
|
|
|
explicit GLGizmoScale3D(GLCanvas3D& parent);
|
2018-08-21 06:50:35 +00:00
|
|
|
|
2018-11-14 11:57:12 +00:00
|
|
|
double get_snap_step(double step) const { return m_snap_step; }
|
|
|
|
void set_snap_step(double step) { m_snap_step = step; }
|
|
|
|
|
2018-09-24 13:54:09 +00:00
|
|
|
const Vec3d& get_scale() const { return m_scale; }
|
2018-10-15 11:22:36 +00:00
|
|
|
void set_scale(const Vec3d& scale) { m_starting_scale = scale; m_scale = scale; }
|
2018-08-21 06:50:35 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool on_init();
|
2018-10-25 07:35:08 +00:00
|
|
|
virtual std::string on_get_name() const;
|
2018-10-16 12:56:35 +00:00
|
|
|
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return !selection.is_wipe_tower(); }
|
2018-10-15 09:30:50 +00:00
|
|
|
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
2019-01-10 12:13:11 +00:00
|
|
|
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection);
|
2018-10-15 09:30:50 +00:00
|
|
|
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
|
|
|
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
2018-08-21 06:50:35 +00:00
|
|
|
|
2018-10-31 09:19:44 +00:00
|
|
|
#if ENABLE_IMGUI
|
2018-11-26 09:56:07 +00:00
|
|
|
virtual void on_render_input_window(float x, float y, const GLCanvas3D::Selection& selection);
|
2018-10-31 09:19:44 +00:00
|
|
|
#endif // ENABLE_IMGUI
|
|
|
|
|
2018-08-21 12:27:36 +00:00
|
|
|
private:
|
|
|
|
void render_grabbers_connection(unsigned int id_1, unsigned int id_2) const;
|
2018-08-21 06:50:35 +00:00
|
|
|
|
2018-11-14 11:57:12 +00:00
|
|
|
void do_scale_x(const UpdateData& data);
|
|
|
|
void do_scale_y(const UpdateData& data);
|
|
|
|
void do_scale_z(const UpdateData& data);
|
|
|
|
void do_scale_uniform(const UpdateData& data);
|
2018-08-22 09:22:07 +00:00
|
|
|
|
2018-11-14 11:57:12 +00:00
|
|
|
double calc_ratio(const UpdateData& data) const;
|
2018-08-21 06:50:35 +00:00
|
|
|
};
|
|
|
|
|
2018-09-11 07:00:28 +00:00
|
|
|
class GLGizmoMove3D : public GLGizmoBase
|
|
|
|
{
|
|
|
|
static const double Offset;
|
|
|
|
|
2018-10-08 12:02:12 +00:00
|
|
|
Vec3d m_displacement;
|
2018-11-14 12:29:57 +00:00
|
|
|
|
|
|
|
double m_snap_step;
|
|
|
|
|
2018-09-11 07:00:28 +00:00
|
|
|
Vec3d m_starting_drag_position;
|
|
|
|
Vec3d m_starting_box_center;
|
2018-09-14 12:37:13 +00:00
|
|
|
Vec3d m_starting_box_bottom_center;
|
2018-09-11 07:00:28 +00:00
|
|
|
|
2018-12-03 08:37:46 +00:00
|
|
|
GLUquadricObj* m_quadric;
|
|
|
|
|
2018-09-11 07:00:28 +00:00
|
|
|
public:
|
|
|
|
explicit GLGizmoMove3D(GLCanvas3D& parent);
|
2018-12-03 08:37:46 +00:00
|
|
|
virtual ~GLGizmoMove3D();
|
2018-09-11 07:00:28 +00:00
|
|
|
|
2018-11-14 12:29:57 +00:00
|
|
|
double get_snap_step(double step) const { return m_snap_step; }
|
|
|
|
void set_snap_step(double step) { m_snap_step = step; }
|
|
|
|
|
2018-10-08 12:02:12 +00:00
|
|
|
const Vec3d& get_displacement() const { return m_displacement; }
|
2018-09-11 07:00:28 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool on_init();
|
2018-10-25 07:35:08 +00:00
|
|
|
virtual std::string on_get_name() const;
|
2018-10-15 09:30:50 +00:00
|
|
|
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
2018-10-24 11:28:35 +00:00
|
|
|
virtual void on_stop_dragging();
|
2019-01-10 12:13:11 +00:00
|
|
|
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection);
|
2018-10-15 09:30:50 +00:00
|
|
|
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
|
|
|
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
2018-09-11 07:00:28 +00:00
|
|
|
|
2018-10-31 09:19:44 +00:00
|
|
|
#if ENABLE_IMGUI
|
2018-11-26 09:56:07 +00:00
|
|
|
virtual void on_render_input_window(float x, float y, const GLCanvas3D::Selection& selection);
|
2018-10-31 09:19:44 +00:00
|
|
|
#endif // ENABLE_IMGUI
|
|
|
|
|
2018-09-11 07:00:28 +00:00
|
|
|
private:
|
2018-11-14 11:57:12 +00:00
|
|
|
double calc_projection(const UpdateData& data) const;
|
2018-12-03 07:51:18 +00:00
|
|
|
void render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking) const;
|
2018-09-11 07:00:28 +00:00
|
|
|
};
|
|
|
|
|
2018-08-09 14:55:43 +00:00
|
|
|
class GLGizmoFlatten : public GLGizmoBase
|
|
|
|
{
|
|
|
|
// This gizmo does not use grabbers. The m_hover_id relates to polygon managed by the class itself.
|
|
|
|
|
|
|
|
private:
|
2018-08-27 12:00:53 +00:00
|
|
|
mutable Vec3d m_normal;
|
2018-08-09 14:55:43 +00:00
|
|
|
|
|
|
|
struct PlaneData {
|
2018-08-27 12:00:53 +00:00
|
|
|
std::vector<Vec3d> vertices;
|
|
|
|
Vec3d normal;
|
2018-08-21 13:56:40 +00:00
|
|
|
float area;
|
2018-08-17 13:40:47 +00:00
|
|
|
};
|
2018-08-09 14:55:43 +00:00
|
|
|
|
2018-08-17 13:40:47 +00:00
|
|
|
// This holds information to decide whether recalculation is necessary:
|
2018-11-28 10:37:17 +00:00
|
|
|
std::vector<Transform3d> m_volumes_matrices;
|
2019-01-04 16:47:08 +00:00
|
|
|
std::vector<ModelVolume::Type> m_volumes_types;
|
|
|
|
Vec3d m_first_instance_scale;
|
2019-01-21 11:53:30 +00:00
|
|
|
Vec3d m_first_instance_mirror;
|
2018-08-17 13:40:47 +00:00
|
|
|
|
2018-08-09 14:55:43 +00:00
|
|
|
std::vector<PlaneData> m_planes;
|
2019-01-26 17:51:34 +00:00
|
|
|
bool m_planes_valid = false;
|
2018-09-26 11:54:09 +00:00
|
|
|
mutable Vec3d m_starting_center;
|
2018-08-17 13:40:47 +00:00
|
|
|
const ModelObject* m_model_object = nullptr;
|
2018-11-02 14:20:26 +00:00
|
|
|
std::vector<const Transform3d*> instances_matrices;
|
2018-08-27 12:00:53 +00:00
|
|
|
|
2018-08-17 13:40:47 +00:00
|
|
|
void update_planes();
|
|
|
|
bool is_plane_update_necessary() const;
|
2018-08-09 14:55:43 +00:00
|
|
|
|
|
|
|
public:
|
2018-08-27 12:00:53 +00:00
|
|
|
explicit GLGizmoFlatten(GLCanvas3D& parent);
|
2018-08-09 14:55:43 +00:00
|
|
|
|
2018-08-17 13:40:47 +00:00
|
|
|
void set_flattening_data(const ModelObject* model_object);
|
2018-11-02 14:20:26 +00:00
|
|
|
Vec3d get_flattening_normal() const;
|
2018-08-09 14:55:43 +00:00
|
|
|
|
|
|
|
protected:
|
2018-08-27 12:00:53 +00:00
|
|
|
virtual bool on_init();
|
2018-10-25 07:35:08 +00:00
|
|
|
virtual std::string on_get_name() const;
|
2018-11-28 11:06:17 +00:00
|
|
|
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const;
|
2018-10-15 09:30:50 +00:00
|
|
|
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
2019-01-10 12:13:11 +00:00
|
|
|
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection) {}
|
2018-10-15 09:30:50 +00:00
|
|
|
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
|
|
|
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
2018-09-10 08:01:49 +00:00
|
|
|
virtual void on_set_state()
|
|
|
|
{
|
2018-08-17 13:40:47 +00:00
|
|
|
if (m_state == On && is_plane_update_necessary())
|
|
|
|
update_planes();
|
|
|
|
}
|
2018-08-09 14:55:43 +00:00
|
|
|
};
|
|
|
|
|
2018-09-12 10:14:20 +00:00
|
|
|
class GLGizmoSlaSupports : public GLGizmoBase
|
|
|
|
{
|
|
|
|
private:
|
2018-09-24 11:39:44 +00:00
|
|
|
ModelObject* m_model_object = nullptr;
|
2018-12-03 13:02:58 +00:00
|
|
|
ModelObject* m_old_model_object = nullptr;
|
|
|
|
int m_old_instance_id = -1;
|
2018-09-19 12:59:57 +00:00
|
|
|
Vec3f unproject_on_mesh(const Vec2d& mouse_pos);
|
|
|
|
|
2018-12-03 13:02:58 +00:00
|
|
|
GLUquadricObj* m_quadric;
|
2018-09-19 12:59:57 +00:00
|
|
|
Eigen::MatrixXf m_V; // vertices
|
|
|
|
Eigen::MatrixXi m_F; // facets indices
|
2018-11-26 09:49:25 +00:00
|
|
|
igl::AABB<Eigen::MatrixXf,3> m_AABB;
|
|
|
|
|
2018-09-24 11:39:44 +00:00
|
|
|
struct SourceDataSummary {
|
|
|
|
Vec3d mesh_first_point;
|
|
|
|
};
|
|
|
|
|
|
|
|
// This holds information to decide whether recalculation is necessary:
|
|
|
|
SourceDataSummary m_source_data;
|
2018-09-12 10:14:20 +00:00
|
|
|
|
2018-09-26 11:54:09 +00:00
|
|
|
mutable Vec3d m_starting_center;
|
|
|
|
|
2018-09-12 10:14:20 +00:00
|
|
|
public:
|
|
|
|
explicit GLGizmoSlaSupports(GLCanvas3D& parent);
|
2018-12-03 13:02:58 +00:00
|
|
|
virtual ~GLGizmoSlaSupports();
|
|
|
|
void set_sla_support_data(ModelObject* model_object, const GLCanvas3D::Selection& selection);
|
2018-09-19 12:59:57 +00:00
|
|
|
void clicked_on_object(const Vec2d& mouse_position);
|
|
|
|
void delete_current_grabber(bool delete_all);
|
2018-09-12 10:14:20 +00:00
|
|
|
|
2018-09-19 12:59:57 +00:00
|
|
|
private:
|
|
|
|
bool on_init();
|
2019-01-10 12:13:11 +00:00
|
|
|
void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection);
|
2018-10-26 13:45:52 +00:00
|
|
|
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
|
|
|
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
|
|
|
|
2018-12-03 13:02:58 +00:00
|
|
|
void render_grabbers(const GLCanvas3D::Selection& selection, bool picking = false) const;
|
2018-09-24 11:39:44 +00:00
|
|
|
bool is_mesh_update_necessary() const;
|
|
|
|
void update_mesh();
|
2018-09-19 12:59:57 +00:00
|
|
|
|
2018-11-27 10:28:00 +00:00
|
|
|
#if !ENABLE_IMGUI
|
2018-11-26 14:54:12 +00:00
|
|
|
void render_tooltip_texture() const;
|
2018-09-19 12:59:57 +00:00
|
|
|
mutable GLTexture m_tooltip_texture;
|
|
|
|
mutable GLTexture m_reset_texture;
|
2018-11-26 14:54:12 +00:00
|
|
|
#endif // not ENABLE_IMGUI
|
2018-09-24 11:39:44 +00:00
|
|
|
|
2019-01-30 07:26:23 +00:00
|
|
|
bool m_lock_unique_islands = false;
|
|
|
|
bool m_editing_mode = false;
|
|
|
|
float m_new_point_head_diameter = 0.4f;
|
2019-02-01 15:12:00 +00:00
|
|
|
std::vector<sla::SupportPoint> m_editing_mode_cache;
|
2019-01-30 07:26:23 +00:00
|
|
|
|
2018-09-24 11:39:44 +00:00
|
|
|
protected:
|
2019-02-01 15:12:00 +00:00
|
|
|
void on_set_state() override;
|
2018-11-06 17:01:18 +00:00
|
|
|
|
2018-11-26 14:54:12 +00:00
|
|
|
#if ENABLE_IMGUI
|
|
|
|
virtual void on_render_input_window(float x, float y, const GLCanvas3D::Selection& selection) override;
|
|
|
|
#endif // ENABLE_IMGUI
|
|
|
|
|
2018-11-19 13:46:37 +00:00
|
|
|
virtual std::string on_get_name() const;
|
|
|
|
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const;
|
|
|
|
virtual bool on_is_selectable() const;
|
2018-09-12 10:14:20 +00:00
|
|
|
};
|
|
|
|
|
2018-10-18 13:13:38 +00:00
|
|
|
|
2018-11-27 10:28:00 +00:00
|
|
|
#if !ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
class GLGizmoCutPanel;
|
2018-11-26 09:56:07 +00:00
|
|
|
#endif // not ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
|
|
|
|
class GLGizmoCut : public GLGizmoBase
|
|
|
|
{
|
|
|
|
static const double Offset;
|
|
|
|
static const double Margin;
|
|
|
|
static const std::array<float, 3> GrabberColor;
|
|
|
|
|
2018-11-29 11:21:42 +00:00
|
|
|
mutable double m_cut_z;
|
2018-10-18 13:13:38 +00:00
|
|
|
double m_start_z;
|
2018-11-29 11:21:42 +00:00
|
|
|
mutable double m_max_z;
|
2018-10-18 13:13:38 +00:00
|
|
|
Vec3d m_drag_pos;
|
|
|
|
Vec3d m_drag_center;
|
2018-11-26 09:56:07 +00:00
|
|
|
bool m_keep_upper;
|
|
|
|
bool m_keep_lower;
|
|
|
|
bool m_rotate_lower;
|
2018-11-27 10:28:00 +00:00
|
|
|
#if !ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
GLGizmoCutPanel *m_panel;
|
2018-11-26 09:56:07 +00:00
|
|
|
#endif // not ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit GLGizmoCut(GLCanvas3D& parent);
|
|
|
|
|
2018-11-27 10:28:00 +00:00
|
|
|
#if !ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
virtual void create_external_gizmo_widgets(wxWindow *parent);
|
2018-11-26 09:56:07 +00:00
|
|
|
#endif // not ENABLE_IMGUI
|
2018-11-27 10:28:00 +00:00
|
|
|
#if !ENABLE_IMGUI
|
2018-11-26 09:56:07 +00:00
|
|
|
#endif // not ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool on_init();
|
|
|
|
virtual std::string on_get_name() const;
|
|
|
|
virtual void on_set_state();
|
|
|
|
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const;
|
|
|
|
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
2019-01-10 12:13:11 +00:00
|
|
|
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection);
|
2018-10-18 13:13:38 +00:00
|
|
|
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
|
|
|
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
|
|
|
|
2018-11-26 09:56:07 +00:00
|
|
|
#if ENABLE_IMGUI
|
|
|
|
virtual void on_render_input_window(float x, float y, const GLCanvas3D::Selection& selection);
|
|
|
|
#endif // ENABLE_IMGUI
|
2018-10-18 13:13:38 +00:00
|
|
|
private:
|
2018-11-29 11:21:42 +00:00
|
|
|
void update_max_z(const GLCanvas3D::Selection& selection) const;
|
|
|
|
void set_cut_z(double cut_z) const;
|
2018-11-26 09:56:07 +00:00
|
|
|
void perform_cut(const GLCanvas3D::Selection& selection);
|
2018-10-18 13:13:38 +00:00
|
|
|
double calc_projection(const Linef3& mouse_ray) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-06-13 07:12:16 +00:00
|
|
|
} // namespace GUI
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif // slic3r_GLGizmo_hpp_
|
|
|
|
|