2019-09-20 12:42:08 +02:00
|
|
|
#ifndef slic3r_GLGizmoFdmSupports_hpp_
|
|
|
|
|
#define slic3r_GLGizmoFdmSupports_hpp_
|
|
|
|
|
|
|
|
|
|
#include "GLGizmoBase.hpp"
|
|
|
|
|
|
2020-04-09 13:16:39 +02:00
|
|
|
#include "slic3r/GUI/3DScene.hpp"
|
|
|
|
|
|
2020-05-26 11:48:09 +02:00
|
|
|
#include "libslic3r/ObjectID.hpp"
|
2020-07-09 16:25:34 +02:00
|
|
|
#include "libslic3r/TriangleSelector.hpp"
|
2020-05-26 11:48:09 +02:00
|
|
|
|
2019-09-20 12:42:08 +02:00
|
|
|
#include <cereal/types/vector.hpp>
|
|
|
|
|
|
|
|
|
|
|
2020-06-23 16:07:33 +02:00
|
|
|
|
|
|
|
|
|
2019-09-20 12:42:08 +02:00
|
|
|
namespace Slic3r {
|
2020-04-16 14:42:42 +02:00
|
|
|
|
|
|
|
|
enum class FacetSupportType : int8_t;
|
|
|
|
|
|
2019-09-20 12:42:08 +02:00
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
|
|
enum class SLAGizmoEventType : unsigned char;
|
2020-05-26 11:48:09 +02:00
|
|
|
class ClippingPlane;
|
2019-09-20 12:42:08 +02:00
|
|
|
|
2020-06-11 13:09:34 +02:00
|
|
|
|
2020-07-09 16:25:34 +02:00
|
|
|
|
|
|
|
|
class TriangleSelectorGUI : public TriangleSelector {
|
2020-06-11 13:09:34 +02:00
|
|
|
public:
|
2020-07-09 16:25:34 +02:00
|
|
|
explicit TriangleSelectorGUI(const TriangleMesh& mesh)
|
|
|
|
|
: TriangleSelector(mesh) {}
|
2020-06-11 13:09:34 +02:00
|
|
|
|
2020-06-23 16:07:33 +02:00
|
|
|
// Render current selection. Transformation matrices are supposed
|
|
|
|
|
// to be already set.
|
|
|
|
|
void render(ImGuiWrapper* imgui = nullptr);
|
|
|
|
|
|
|
|
|
|
#ifdef PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
|
|
|
|
void render_debug(ImGuiWrapper* imgui);
|
2020-07-09 16:25:34 +02:00
|
|
|
bool m_show_triangles{false};
|
2020-06-24 12:24:32 +02:00
|
|
|
bool m_show_invalid{false};
|
2020-06-23 16:07:33 +02:00
|
|
|
#endif
|
|
|
|
|
|
2020-06-11 13:09:34 +02:00
|
|
|
private:
|
2020-07-01 09:09:25 +02:00
|
|
|
GLIndexedVertexArray m_iva_enforcers;
|
|
|
|
|
GLIndexedVertexArray m_iva_blockers;
|
|
|
|
|
std::array<GLIndexedVertexArray, 3> m_varrays;
|
2020-06-11 13:09:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-20 12:42:08 +02:00
|
|
|
class GLGizmoFdmSupports : public GLGizmoBase
|
|
|
|
|
{
|
|
|
|
|
private:
|
2020-05-05 13:45:04 +02:00
|
|
|
ObjectID m_old_mo_id;
|
2020-04-08 00:34:05 +02:00
|
|
|
size_t m_old_volumes_size = 0;
|
2019-09-20 12:42:08 +02:00
|
|
|
|
|
|
|
|
GLUquadricObj* m_quadric;
|
|
|
|
|
|
2019-10-08 10:15:06 +02:00
|
|
|
float m_cursor_radius = 2.f;
|
2020-07-24 17:45:49 +02:00
|
|
|
static constexpr float CursorRadiusMin = 0.4f; // cannot be zero
|
2020-04-08 15:21:41 +02:00
|
|
|
static constexpr float CursorRadiusMax = 8.f;
|
|
|
|
|
static constexpr float CursorRadiusStep = 0.2f;
|
2019-09-20 12:42:08 +02:00
|
|
|
|
2020-07-09 16:25:34 +02:00
|
|
|
// For each model-part volume, store status and division of the triangles.
|
|
|
|
|
std::vector<std::unique_ptr<TriangleSelectorGUI>> m_triangle_selectors;
|
2020-05-15 18:31:55 +02:00
|
|
|
|
2019-09-20 12:42:08 +02:00
|
|
|
public:
|
|
|
|
|
GLGizmoFdmSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
|
|
|
|
~GLGizmoFdmSupports() override;
|
|
|
|
|
void set_fdm_support_data(ModelObject* model_object, const Selection& selection);
|
|
|
|
|
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool on_init() override;
|
|
|
|
|
void on_render() const override;
|
2020-05-05 13:45:04 +02:00
|
|
|
void on_render_for_picking() const override {}
|
2019-09-20 12:42:08 +02:00
|
|
|
|
2019-09-26 13:30:22 +02:00
|
|
|
void render_triangles(const Selection& selection) const;
|
2019-10-08 10:15:06 +02:00
|
|
|
void render_cursor_circle() const;
|
2020-05-05 13:45:04 +02:00
|
|
|
|
|
|
|
|
void update_model_object() const;
|
|
|
|
|
void update_from_model_object();
|
2020-06-01 10:01:45 +02:00
|
|
|
void activate_internal_undo_redo_stack(bool activate);
|
2019-09-20 12:42:08 +02:00
|
|
|
|
2020-07-14 14:02:39 +02:00
|
|
|
void select_facets_by_angle(float threshold, bool block);
|
2020-05-06 07:03:32 +02:00
|
|
|
float m_angle_threshold_deg = 45.f;
|
|
|
|
|
|
2020-04-30 16:44:09 +02:00
|
|
|
bool is_mesh_point_clipped(const Vec3d& point) const;
|
|
|
|
|
|
2019-09-20 12:42:08 +02:00
|
|
|
float m_clipping_plane_distance = 0.f;
|
|
|
|
|
std::unique_ptr<ClippingPlane> m_clipping_plane;
|
2020-05-06 07:03:32 +02:00
|
|
|
bool m_setting_angle = false;
|
2020-06-01 10:01:45 +02:00
|
|
|
bool m_internal_stack_active = false;
|
|
|
|
|
bool m_schedule_update = false;
|
2019-09-20 12:42:08 +02:00
|
|
|
|
|
|
|
|
// This map holds all translated description texts, so they can be easily referenced during layout calculations
|
|
|
|
|
// etc. When language changes, GUI is recreated and this class constructed again, so the change takes effect.
|
|
|
|
|
std::map<std::string, wxString> m_desc;
|
|
|
|
|
|
2020-04-08 14:59:53 +02:00
|
|
|
enum class Button {
|
|
|
|
|
None,
|
|
|
|
|
Left,
|
|
|
|
|
Right
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Button m_button_down = Button::None;
|
2019-09-20 12:42:08 +02:00
|
|
|
EState m_old_state = Off; // to be able to see that the gizmo has just been closed (see on_set_state)
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void on_set_state() override;
|
|
|
|
|
void on_start_dragging() override;
|
|
|
|
|
void on_stop_dragging() override;
|
|
|
|
|
void on_render_input_window(float x, float y, float bottom_limit) override;
|
|
|
|
|
std::string on_get_name() const override;
|
|
|
|
|
bool on_is_activable() const override;
|
|
|
|
|
bool on_is_selectable() const override;
|
|
|
|
|
void on_load(cereal::BinaryInputArchive& ar) override;
|
|
|
|
|
void on_save(cereal::BinaryOutputArchive& ar) const override;
|
2020-04-07 19:44:29 +02:00
|
|
|
CommonGizmosDataID on_get_requirements() const override;
|
2019-09-20 12:42:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace GUI
|
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
|
|
#endif // slic3r_GLGizmoFdmSupports_hpp_
|