2019-03-15 11:53:15 +00:00
|
|
|
#ifndef slic3r_GLGizmoSlaSupports_hpp_
|
|
|
|
#define slic3r_GLGizmoSlaSupports_hpp_
|
|
|
|
|
|
|
|
#include "GLGizmoBase.hpp"
|
2019-03-20 12:51:25 +00:00
|
|
|
#include "GLGizmos.hpp"
|
2019-03-15 11:53:15 +00:00
|
|
|
|
|
|
|
// There is an L function in igl that would be overridden by our localization macro - let's undefine it...
|
|
|
|
#undef L
|
|
|
|
#include <igl/AABB.h>
|
|
|
|
#include "slic3r/GUI/I18N.hpp" // ...and redefine again when we are done with the igl code
|
|
|
|
|
|
|
|
#include "libslic3r/SLA/SLACommon.hpp"
|
|
|
|
#include "libslic3r/SLAPrint.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
|
2019-04-08 08:50:10 +00:00
|
|
|
class ClippingPlane;
|
|
|
|
|
|
|
|
|
2019-03-15 11:53:15 +00:00
|
|
|
class GLGizmoSlaSupports : public GLGizmoBase
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
ModelObject* m_model_object = nullptr;
|
2019-04-10 11:32:21 +00:00
|
|
|
ModelID m_current_mesh_model_id = 0;
|
2019-03-15 11:53:15 +00:00
|
|
|
int m_active_instance = -1;
|
2019-04-05 14:38:54 +00:00
|
|
|
float m_active_instance_bb_radius; // to cache the bb
|
|
|
|
mutable float m_z_shift = 0.f;
|
2019-03-15 11:53:15 +00:00
|
|
|
std::pair<Vec3f, Vec3f> unproject_on_mesh(const Vec2d& mouse_pos);
|
|
|
|
|
|
|
|
const float RenderPointScale = 1.f;
|
|
|
|
|
|
|
|
GLUquadricObj* m_quadric;
|
|
|
|
Eigen::MatrixXf m_V; // vertices
|
|
|
|
Eigen::MatrixXi m_F; // facets indices
|
|
|
|
igl::AABB<Eigen::MatrixXf,3> m_AABB;
|
2019-04-15 20:24:10 +00:00
|
|
|
const TriangleMesh* m_mesh;
|
|
|
|
mutable const TriangleMesh* m_supports_mesh;
|
2019-03-27 06:44:02 +00:00
|
|
|
mutable std::vector<Vec2f> m_triangles;
|
2019-04-15 14:20:29 +00:00
|
|
|
mutable std::vector<Vec2f> m_supports_triangles;
|
|
|
|
mutable int m_old_timestamp = -1;
|
|
|
|
mutable int m_print_object_idx = -1;
|
|
|
|
mutable int m_print_objects_count = -1;
|
2019-03-15 11:53:15 +00:00
|
|
|
|
|
|
|
class CacheEntry {
|
|
|
|
public:
|
|
|
|
CacheEntry(const sla::SupportPoint& point, bool sel, const Vec3f& norm = Vec3f::Zero()) :
|
|
|
|
support_point(point), selected(sel), normal(norm) {}
|
|
|
|
|
|
|
|
sla::SupportPoint support_point;
|
|
|
|
bool selected; // whether the point is selected
|
|
|
|
Vec3f normal;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
#if ENABLE_SVG_ICONS
|
|
|
|
GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
|
|
|
#else
|
|
|
|
GLGizmoSlaSupports(GLCanvas3D& parent, unsigned int sprite_id);
|
|
|
|
#endif // ENABLE_SVG_ICONS
|
|
|
|
virtual ~GLGizmoSlaSupports();
|
2019-03-19 12:30:21 +00:00
|
|
|
void set_sla_support_data(ModelObject* model_object, const Selection& selection);
|
2019-04-08 13:34:42 +00:00
|
|
|
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
|
2019-03-15 11:53:15 +00:00
|
|
|
void delete_selected_points(bool force = false);
|
2019-04-08 08:50:10 +00:00
|
|
|
ClippingPlane get_sla_clipping_plane() const;
|
2019-03-15 11:53:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool on_init();
|
2019-03-19 12:30:21 +00:00
|
|
|
void on_update(const UpdateData& data, const Selection& selection);
|
|
|
|
virtual void on_render(const Selection& selection) const;
|
|
|
|
virtual void on_render_for_picking(const Selection& selection) const;
|
2019-03-15 11:53:15 +00:00
|
|
|
|
|
|
|
void render_selection_rectangle() const;
|
2019-04-17 10:24:46 +00:00
|
|
|
void render_points(const Selection& selection, bool picking = false) const;
|
|
|
|
void render_clipping_plane(const Selection& selection) const;
|
2019-03-15 11:53:15 +00:00
|
|
|
bool is_mesh_update_necessary() const;
|
|
|
|
void update_mesh();
|
|
|
|
void update_cache_entry_normal(unsigned int i) const;
|
|
|
|
|
|
|
|
bool m_lock_unique_islands = false;
|
|
|
|
bool m_editing_mode = false; // Is editing mode active?
|
|
|
|
bool m_old_editing_state = false; // To keep track of whether the user toggled between the modes (needed for imgui refreshes).
|
|
|
|
float m_new_point_head_diameter; // Size of a new point.
|
|
|
|
float m_minimal_point_distance = 20.f;
|
|
|
|
mutable std::vector<CacheEntry> m_editing_mode_cache; // a support point and whether it is currently selected
|
|
|
|
float m_clipping_plane_distance = 0.f;
|
2019-03-27 06:44:02 +00:00
|
|
|
mutable float m_old_clipping_plane_distance = 0.f;
|
2019-04-17 10:24:46 +00:00
|
|
|
mutable Vec3d m_old_clipping_plane_normal;
|
|
|
|
mutable Vec3d m_clipping_plane_normal = Vec3d::Zero();
|
2019-03-15 11:53:15 +00:00
|
|
|
|
2019-04-08 13:34:42 +00:00
|
|
|
enum SelectionRectangleStatus {
|
|
|
|
srOff = 0,
|
|
|
|
srSelect = 1,
|
|
|
|
srDeselect = 2
|
|
|
|
}m_selection_rectangle_status = srOff;
|
|
|
|
|
2019-03-15 11:53:15 +00:00
|
|
|
Vec2d m_selection_rectangle_start_corner;
|
|
|
|
Vec2d m_selection_rectangle_end_corner;
|
2019-03-20 13:04:59 +00:00
|
|
|
bool m_wait_for_up_event = false;
|
2019-03-15 11:53:15 +00:00
|
|
|
bool m_unsaved_changes = false; // Are there unsaved changes in manual mode?
|
|
|
|
bool m_selection_empty = true;
|
|
|
|
EState m_old_state = Off; // to be able to see that the gizmo has just been closed (see on_set_state)
|
|
|
|
int m_canvas_width;
|
|
|
|
int m_canvas_height;
|
|
|
|
|
2019-03-27 06:44:02 +00:00
|
|
|
mutable std::unique_ptr<TriangleMeshSlicer> m_tms;
|
2019-04-15 14:20:29 +00:00
|
|
|
mutable std::unique_ptr<TriangleMeshSlicer> m_supports_tms;
|
2019-03-27 06:44:02 +00:00
|
|
|
|
2019-03-15 11:53:15 +00:00
|
|
|
std::vector<const ConfigOption*> get_config_options(const std::vector<std::string>& keys) const;
|
2019-04-17 10:24:46 +00:00
|
|
|
bool is_point_clipped(const Vec3d& point) const;
|
|
|
|
//void find_intersecting_facets(const igl::AABB<Eigen::MatrixXf, 3>* aabb, const Vec3f& normal, double offset, std::vector<unsigned int>& out) const;
|
2019-03-15 11:53:15 +00:00
|
|
|
|
|
|
|
// Methods that do the model_object and editing cache synchronization,
|
|
|
|
// editing mode selection, etc:
|
|
|
|
enum {
|
|
|
|
AllPoints = -2,
|
|
|
|
NoPoints,
|
|
|
|
};
|
|
|
|
void select_point(int i);
|
2019-04-03 12:44:15 +00:00
|
|
|
void unselect_point(int i);
|
2019-03-15 11:53:15 +00:00
|
|
|
void editing_mode_apply_changes();
|
|
|
|
void editing_mode_discard_changes();
|
|
|
|
void editing_mode_reload_cache();
|
|
|
|
void get_data_from_backend();
|
|
|
|
void auto_generate();
|
|
|
|
void switch_to_editing_mode();
|
2019-04-17 10:24:46 +00:00
|
|
|
void reset_clipping_plane_normal() const;
|
2019-03-15 11:53:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void on_set_state() override;
|
2019-03-19 12:30:21 +00:00
|
|
|
void on_start_dragging(const Selection& selection) override;
|
|
|
|
virtual void on_render_input_window(float x, float y, float bottom_limit, const Selection& selection) override;
|
2019-03-15 11:53:15 +00:00
|
|
|
|
|
|
|
virtual std::string on_get_name() const;
|
2019-03-19 12:30:21 +00:00
|
|
|
virtual bool on_is_activable(const Selection& selection) const;
|
2019-03-15 11:53:15 +00:00
|
|
|
virtual bool on_is_selectable() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace GUI
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif // slic3r_GLGizmoSlaSupports_hpp_
|