mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-13 21:36:01 +08:00
ENh:Upgrade data_changed mechanism to avoid unnecessary Gizmo updates and improve efficiency
jira:none code is form PrusaSlicer,thanks for PrusaSlicer and Filip Sykala commit 123903f317f28723073cf3e5fbfe2564e987b6ab Author: Filip Sykala <filip.sykala@prusa3d.cz> Date: Fri Dec 10 14:54:33 2021 +0100 Clean up GLGizmoManagaer Clean up GLGizmoBase Change-Id: Idae429f52499031df66265c92f8ba9fe9fc55eff (cherry picked from commit 1957ad45cc9e9955228c2f00334047c805f97308)
This commit is contained in:
parent
b609a45079
commit
682e70ca94
@ -539,6 +539,7 @@ void GLGizmoAdvancedCut::on_save(cereal::BinaryOutputArchive &ar) const
|
|||||||
|
|
||||||
void GLGizmoAdvancedCut::data_changed(bool is_serializing)
|
void GLGizmoAdvancedCut::data_changed(bool is_serializing)
|
||||||
{
|
{
|
||||||
|
reset_rotation();
|
||||||
if (m_hover_id < 0) { // BBL
|
if (m_hover_id < 0) { // BBL
|
||||||
update_bb();
|
update_bb();
|
||||||
if (auto oc = m_c->object_clipper()) {
|
if (auto oc = m_c->object_clipper()) {
|
||||||
@ -1168,7 +1169,7 @@ Vec3d GLGizmoAdvancedCut::get_plane_center() const {
|
|||||||
return m_plane_center;
|
return m_plane_center;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoAdvancedCut::finish_rotation()
|
void GLGizmoAdvancedCut::reset_rotation()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
m_gizmos[i].set_angle(0.);
|
m_gizmos[i].set_angle(0.);
|
||||||
@ -2013,7 +2014,6 @@ void GLGizmoAdvancedCut::update_bb()
|
|||||||
m_groove.flaps_angle = m_groove.flaps_angle_init = float(PI) / 3.f;
|
m_groove.flaps_angle = m_groove.flaps_angle_init = float(PI) / 3.f;
|
||||||
m_groove.angle = m_groove.angle_init = 0.f;
|
m_groove.angle = m_groove.angle_init = 0.f;
|
||||||
m_plane.reset();
|
m_plane.reset();
|
||||||
|
|
||||||
clear_selection();
|
clear_selection();
|
||||||
if (CommonGizmosDataObjects::SelectionInfo *selection = m_c->selection_info(); selection && selection->model_object())
|
if (CommonGizmosDataObjects::SelectionInfo *selection = m_c->selection_info(); selection && selection->model_object())
|
||||||
m_selected.resize(selection->model_object()->cut_connectors.size(), false);
|
m_selected.resize(selection->model_object()->cut_connectors.size(), false);
|
||||||
|
@ -214,7 +214,7 @@ public:
|
|||||||
bool on_key(const wxKeyEvent &evt) override;
|
bool on_key(const wxKeyEvent &evt) override;
|
||||||
|
|
||||||
double get_movement() const { return m_movement; }
|
double get_movement() const { return m_movement; }
|
||||||
void finish_rotation();
|
void reset_rotation();
|
||||||
std::string get_tooltip() const override;
|
std::string get_tooltip() const override;
|
||||||
|
|
||||||
BoundingBoxf3 bounding_box() const;
|
BoundingBoxf3 bounding_box() const;
|
||||||
|
@ -368,6 +368,14 @@ void GLGizmoBase::set_highlight_color(const std::array<float, 4>& color)
|
|||||||
m_highlight_color = color;
|
m_highlight_color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLGizmoBase::enable_grabber(unsigned int id , bool enable) {
|
||||||
|
if (enable) {
|
||||||
|
enable_grabber(id);
|
||||||
|
} else {
|
||||||
|
disable_grabber(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GLGizmoBase::enable_grabber(unsigned int id)
|
void GLGizmoBase::enable_grabber(unsigned int id)
|
||||||
{
|
{
|
||||||
if (id < m_grabbers.size())
|
if (id < m_grabbers.size())
|
||||||
|
@ -221,6 +221,7 @@ public:
|
|||||||
|
|
||||||
void set_highlight_color(const std::array<float, 4>& color);
|
void set_highlight_color(const std::array<float, 4>& color);
|
||||||
|
|
||||||
|
void enable_grabber(unsigned int id, bool enable);
|
||||||
void enable_grabber(unsigned int id);
|
void enable_grabber(unsigned int id);
|
||||||
void disable_grabber(unsigned int id);
|
void disable_grabber(unsigned int id);
|
||||||
|
|
||||||
|
@ -58,18 +58,6 @@ bool GLGizmoBrimEars::on_init()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoBrimEars::set_brim_data(ModelObject *model_object, const Selection &selection)
|
|
||||||
{
|
|
||||||
if (!m_c->selection_info()) return;
|
|
||||||
|
|
||||||
ModelObject *mo = m_c->selection_info()->model_object();
|
|
||||||
|
|
||||||
if (m_state == On && mo && mo->id() != m_old_mo_id) {
|
|
||||||
reload_cache();
|
|
||||||
m_old_mo_id = mo->id();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmoBrimEars::on_render()
|
void GLGizmoBrimEars::on_render()
|
||||||
{
|
{
|
||||||
ModelObject *mo = m_c->selection_info()->model_object();
|
ModelObject *mo = m_c->selection_info()->model_object();
|
||||||
@ -286,6 +274,19 @@ void GLGizmoBrimEars::data_changed(bool is_serializing)
|
|||||||
reset_all_pick();
|
reset_all_pick();
|
||||||
register_single_mesh_pick();
|
register_single_mesh_pick();
|
||||||
}
|
}
|
||||||
|
set_brim_data();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLGizmoBrimEars::set_brim_data()
|
||||||
|
{
|
||||||
|
if (!m_c->selection_info()) return;
|
||||||
|
|
||||||
|
ModelObject *mo = m_c->selection_info()->model_object();
|
||||||
|
|
||||||
|
if (m_state == On && mo && mo->id() != m_old_mo_id) {
|
||||||
|
reload_cache();
|
||||||
|
m_old_mo_id = mo->id();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Following function is called from GLCanvas3D to inform the gizmo about a mouse/keyboard event.
|
// Following function is called from GLCanvas3D to inform the gizmo about a mouse/keyboard event.
|
||||||
|
@ -75,7 +75,6 @@ public:
|
|||||||
GLGizmoBrimEars(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
GLGizmoBrimEars(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||||
virtual ~GLGizmoBrimEars() = default;
|
virtual ~GLGizmoBrimEars() = default;
|
||||||
void data_changed(bool is_serializing) override;
|
void data_changed(bool is_serializing) override;
|
||||||
void set_brim_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);
|
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
|
||||||
void delete_selected_points();
|
void delete_selected_points();
|
||||||
void update_model_object();
|
void update_model_object();
|
||||||
@ -88,6 +87,7 @@ public:
|
|||||||
std::string get_gizmo_leaving_text() const override { return "Leaving Brim Ears"; }
|
std::string get_gizmo_leaving_text() const override { return "Leaving Brim Ears"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void set_brim_data();
|
||||||
bool on_init() override;
|
bool on_init() override;
|
||||||
void on_update(const UpdateData& data) override;
|
void on_update(const UpdateData& data) override;
|
||||||
void on_render() override;
|
void on_render() override;
|
||||||
|
@ -29,6 +29,10 @@ GLGizmoFdmSupports::GLGizmoFdmSupports(GLCanvas3D& parent, const std::string& ic
|
|||||||
m_cursor_type = TriangleSelector::CursorType::CIRCLE;
|
m_cursor_type = TriangleSelector::CursorType::CIRCLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLGizmoFdmSupports::data_changed(bool is_serializing) {
|
||||||
|
set_painter_gizmo_data(m_parent.get_selection());
|
||||||
|
}
|
||||||
|
|
||||||
void GLGizmoFdmSupports::on_shutdown()
|
void GLGizmoFdmSupports::on_shutdown()
|
||||||
{
|
{
|
||||||
//BBS
|
//BBS
|
||||||
|
@ -14,7 +14,7 @@ class GLGizmoFdmSupports : public GLGizmoPainterBase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GLGizmoFdmSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
GLGizmoFdmSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||||
|
void data_changed(bool is_serializing) override;
|
||||||
void render_painter_gizmo() const override;
|
void render_painter_gizmo() const override;
|
||||||
|
|
||||||
//BBS: add edit state
|
//BBS: add edit state
|
||||||
|
@ -292,15 +292,6 @@ void GLGizmoFlatten::on_render_for_picking()
|
|||||||
glsafe(::glEnable(GL_CULL_FACE));
|
glsafe(::glEnable(GL_CULL_FACE));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoFlatten::set_flattening_data(const ModelObject* model_object)
|
|
||||||
{
|
|
||||||
m_starting_center = Vec3d::Zero();
|
|
||||||
if (model_object != m_old_model_object) {
|
|
||||||
m_planes.clear();
|
|
||||||
m_planes_valid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmoFlatten::update_planes()
|
void GLGizmoFlatten::update_planes()
|
||||||
{
|
{
|
||||||
const ModelObject* mo = m_c->selection_info()->model_object();
|
const ModelObject* mo = m_c->selection_info()->model_object();
|
||||||
@ -532,7 +523,7 @@ void GLGizmoFlatten::update_planes()
|
|||||||
m_first_instance_scale = mo->instances.front()->get_scaling_factor();
|
m_first_instance_scale = mo->instances.front()->get_scaling_factor();
|
||||||
m_first_instance_mirror = mo->instances.front()->get_mirror();
|
m_first_instance_mirror = mo->instances.front()->get_mirror();
|
||||||
m_old_model_object = mo;
|
m_old_model_object = mo;
|
||||||
|
m_old_instance_id = m_c->selection_info()->get_active_instance();
|
||||||
// And finally create respective VBOs. The polygon is convex with
|
// And finally create respective VBOs. The polygon is convex with
|
||||||
// the vertices in order, so triangulation is trivial.
|
// the vertices in order, so triangulation is trivial.
|
||||||
for (auto& plane : m_planes) {
|
for (auto& plane : m_planes) {
|
||||||
@ -583,5 +574,21 @@ Vec3d GLGizmoFlatten::get_flattening_normal() const
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLGizmoFlatten::data_changed(bool is_serializing)
|
||||||
|
{
|
||||||
|
const Selection & selection = m_parent.get_selection();
|
||||||
|
const ModelObject *model_object = nullptr;
|
||||||
|
int instance_id = -1;
|
||||||
|
if (selection.is_single_full_instance() || selection.is_from_single_object()) {
|
||||||
|
model_object = selection.get_model()->objects[selection.get_object_idx()];
|
||||||
|
instance_id = selection.get_instance_idx();
|
||||||
|
}
|
||||||
|
m_starting_center = Vec3d::Zero();
|
||||||
|
if (model_object != m_old_model_object || instance_id != m_old_instance_id) {
|
||||||
|
m_planes.clear();
|
||||||
|
m_planes_valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
@ -47,8 +47,8 @@ private:
|
|||||||
public:
|
public:
|
||||||
GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||||
|
|
||||||
void set_flattening_data(const ModelObject* model_object);
|
|
||||||
Vec3d get_flattening_normal() const;
|
Vec3d get_flattening_normal() const;
|
||||||
|
void data_changed(bool is_serializing) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool on_init() override;
|
virtual bool on_init() override;
|
||||||
@ -68,6 +68,7 @@ private:
|
|||||||
mutable int m_last_hit_facet;
|
mutable int m_last_hit_facet;
|
||||||
mutable GLModel m_one_tri_model;
|
mutable GLModel m_one_tri_model;
|
||||||
Vec3f m_hit_object_normal;
|
Vec3f m_hit_object_normal;
|
||||||
|
int m_old_instance_id{-1};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool update_raycast_cache(const Vec2d &mouse_position, const Camera &camera, const std::vector<Transform3d> &trafo_matrices, int &facet);
|
bool update_raycast_cache(const Vec2d &mouse_position, const Camera &camera, const std::vector<Transform3d> &trafo_matrices, int &facet);
|
||||||
|
@ -142,6 +142,10 @@ GLGizmoMmuSegmentation::GLGizmoMmuSegmentation(GLCanvas3D& parent, const std::st
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLGizmoMmuSegmentation::data_changed(bool is_serializing) {
|
||||||
|
set_painter_gizmo_data(m_parent.get_selection());
|
||||||
|
}
|
||||||
|
|
||||||
void GLGizmoMmuSegmentation::render_painter_gizmo() const
|
void GLGizmoMmuSegmentation::render_painter_gizmo() const
|
||||||
{
|
{
|
||||||
const Selection& selection = m_parent.get_selection();
|
const Selection& selection = m_parent.get_selection();
|
||||||
|
@ -66,11 +66,9 @@ class GLGizmoMmuSegmentation : public GLGizmoPainterBase
|
|||||||
public:
|
public:
|
||||||
GLGizmoMmuSegmentation(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
GLGizmoMmuSegmentation(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||||
~GLGizmoMmuSegmentation() override = default;
|
~GLGizmoMmuSegmentation() override = default;
|
||||||
|
void data_changed(bool is_serializing) override;
|
||||||
void render_painter_gizmo() const override;
|
void render_painter_gizmo() const override;
|
||||||
void render_non_manifold_edges() const;
|
void render_non_manifold_edges() const;
|
||||||
void set_painter_gizmo_data(const Selection& selection) override;
|
|
||||||
|
|
||||||
void render_triangles(const Selection& selection) const override;
|
void render_triangles(const Selection& selection) const override;
|
||||||
|
|
||||||
// TriangleSelector::serialization/deserialization has a limit to store 19 different states.
|
// TriangleSelector::serialization/deserialization has a limit to store 19 different states.
|
||||||
@ -87,6 +85,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// BBS
|
// BBS
|
||||||
|
void set_painter_gizmo_data(const Selection &selection) override;
|
||||||
std::array<float, 4> get_cursor_hover_color() const override;
|
std::array<float, 4> get_cursor_hover_color() const override;
|
||||||
void on_set_state() override;
|
void on_set_state() override;
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ std::string GLGizmoMove3D::get_tooltip() const
|
|||||||
|
|
||||||
void GLGizmoMove3D::data_changed(bool is_serializing)
|
void GLGizmoMove3D::data_changed(bool is_serializing)
|
||||||
{
|
{
|
||||||
|
enable_grabber(2, !m_parent.get_selection().is_wipe_tower());
|
||||||
change_cs_by_selection();
|
change_cs_by_selection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +222,6 @@ private:
|
|||||||
public:
|
public:
|
||||||
GLGizmoPainterBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
GLGizmoPainterBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||||
~GLGizmoPainterBase() override = default;
|
~GLGizmoPainterBase() override = default;
|
||||||
virtual void set_painter_gizmo_data(const Selection& selection);
|
|
||||||
virtual bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
|
virtual bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
|
||||||
|
|
||||||
// Following function renders the triangles and cursor. Having this separated
|
// Following function renders the triangles and cursor. Having this separated
|
||||||
@ -242,6 +241,7 @@ public:
|
|||||||
void update_front_view_radian();
|
void update_front_view_radian();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void set_painter_gizmo_data(const Selection &selection);
|
||||||
virtual void render_triangles(const Selection& selection) const;
|
virtual void render_triangles(const Selection& selection) const;
|
||||||
void render_cursor() const;
|
void render_cursor() const;
|
||||||
void render_cursor_circle() const;
|
void render_cursor_circle() const;
|
||||||
|
@ -689,6 +689,14 @@ void GLGizmoRotate3D::on_set_state()
|
|||||||
|
|
||||||
void GLGizmoRotate3D::data_changed(bool is_serializing) {
|
void GLGizmoRotate3D::data_changed(bool is_serializing) {
|
||||||
const Selection &selection = m_parent.get_selection();
|
const Selection &selection = m_parent.get_selection();
|
||||||
|
enable_grabber(0, !selection.is_wipe_tower());
|
||||||
|
enable_grabber(1, !selection.is_wipe_tower());
|
||||||
|
if (selection.is_wipe_tower()) {
|
||||||
|
DynamicPrintConfig &config = wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||||
|
set_rotation(Vec3d(0., 0., (M_PI / 180.) * dynamic_cast<const ConfigOptionFloat *>(config.option("wipe_tower_rotation_angle"))->value));
|
||||||
|
} else {
|
||||||
|
set_rotation(Vec3d::Zero());
|
||||||
|
}
|
||||||
const GLVolume * volume = selection.get_first_volume();
|
const GLVolume * volume = selection.get_first_volume();
|
||||||
if (volume == nullptr) {
|
if (volume == nullptr) {
|
||||||
m_last_volume = nullptr;
|
m_last_volume = nullptr;
|
||||||
|
@ -84,6 +84,12 @@ std::string GLGizmoScale3D::get_tooltip() const
|
|||||||
|
|
||||||
void GLGizmoScale3D::data_changed(bool is_serializing)
|
void GLGizmoScale3D::data_changed(bool is_serializing)
|
||||||
{
|
{
|
||||||
|
const Selection &selection = m_parent.get_selection();
|
||||||
|
bool enable_scale_xyz = selection.is_single_full_instance() || selection.is_single_volume_or_modifier();
|
||||||
|
for (unsigned int i = 0; i < 6; ++i)
|
||||||
|
m_grabbers[i].enabled = enable_scale_xyz;
|
||||||
|
set_scale(Vec3d::Ones());
|
||||||
|
|
||||||
change_cs_by_selection();
|
change_cs_by_selection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,10 @@ GLGizmoSeam::GLGizmoSeam(GLCanvas3D& parent, const std::string& icon_filename, u
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLGizmoSeam::data_changed(bool is_serializing) {
|
||||||
|
set_painter_gizmo_data(m_parent.get_selection());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string GLGizmoSeam::on_get_name() const
|
std::string GLGizmoSeam::on_get_name() const
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@ class GLGizmoSeam : public GLGizmoPainterBase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GLGizmoSeam(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
GLGizmoSeam(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||||
|
void data_changed(bool is_serializing) override;
|
||||||
void render_painter_gizmo() const override;
|
void render_painter_gizmo() const override;
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
|
@ -439,17 +439,6 @@ void GLGizmosManager::set_hover_id(int id)
|
|||||||
m_gizmos[m_current]->set_hover_id(id);
|
m_gizmos[m_current]->set_hover_id(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmosManager::enable_grabber(EType type, unsigned int id, bool enable)
|
|
||||||
{
|
|
||||||
if (!m_enabled || type == Undefined || m_gizmos.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (enable)
|
|
||||||
m_gizmos[type]->enable_grabber(id);
|
|
||||||
else
|
|
||||||
m_gizmos[type]->disable_grabber(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmosManager::update(const Linef3& mouse_ray, const Point& mouse_pos)
|
void GLGizmosManager::update(const Linef3& mouse_ray, const Point& mouse_pos)
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
@ -476,19 +465,6 @@ void GLGizmosManager::update_data()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const Selection& selection = m_parent.get_selection();
|
const Selection& selection = m_parent.get_selection();
|
||||||
|
|
||||||
bool is_wipe_tower = selection.is_wipe_tower();
|
|
||||||
enable_grabber(Move, 2, !is_wipe_tower);
|
|
||||||
enable_grabber(Rotate, 0, !is_wipe_tower);
|
|
||||||
enable_grabber(Rotate, 1, !is_wipe_tower);
|
|
||||||
|
|
||||||
// BBS: when select multiple objects, uniform scale can be deselected, display the 0-5 grabbers
|
|
||||||
//bool enable_scale_xyz = selection.is_single_full_instance() || selection.is_single_volume() || selection.is_single_modifier();
|
|
||||||
//for (unsigned int i = 0; i < 6; ++i)
|
|
||||||
//{
|
|
||||||
// enable_grabber(Scale, i, enable_scale_xyz);
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (m_common_gizmos_data) {
|
if (m_common_gizmos_data) {
|
||||||
m_common_gizmos_data->update(get_current()
|
m_common_gizmos_data->update(get_current()
|
||||||
? get_current()->get_requirements()
|
? get_current()->get_requirements()
|
||||||
@ -497,56 +473,12 @@ void GLGizmosManager::update_data()
|
|||||||
if (m_current != Undefined)
|
if (m_current != Undefined)
|
||||||
m_gizmos[m_current]->data_changed(m_serializing);
|
m_gizmos[m_current]->data_changed(m_serializing);
|
||||||
|
|
||||||
if (selection.is_single_full_instance())
|
|
||||||
{
|
|
||||||
// all volumes in the selection belongs to the same instance, any of them contains the needed data, so we take the first
|
|
||||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
|
||||||
set_scale(volume->get_instance_scaling_factor());
|
|
||||||
set_rotation(Vec3d::Zero());
|
|
||||||
// BBS
|
|
||||||
finish_cut_rotation();
|
|
||||||
ModelObject* model_object = selection.get_model()->objects[selection.get_object_idx()];
|
|
||||||
set_flattening_data(model_object);
|
|
||||||
set_sla_support_data(model_object);
|
|
||||||
set_brim_data(model_object);
|
|
||||||
set_painter_gizmo_data();
|
|
||||||
}
|
|
||||||
else if (selection.is_single_volume() || selection.is_single_modifier())
|
|
||||||
{
|
|
||||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
|
||||||
set_scale(volume->get_volume_scaling_factor());
|
|
||||||
set_rotation(Vec3d::Zero());
|
|
||||||
// BBS
|
|
||||||
finish_cut_rotation();
|
|
||||||
set_flattening_data(nullptr);
|
|
||||||
set_sla_support_data(nullptr);
|
|
||||||
set_brim_data(nullptr);
|
|
||||||
set_painter_gizmo_data();
|
|
||||||
}
|
|
||||||
else if (is_wipe_tower)
|
|
||||||
{
|
|
||||||
DynamicPrintConfig& proj_cfg = wxGetApp().preset_bundle->project_config;
|
|
||||||
set_scale(Vec3d::Ones());
|
|
||||||
set_rotation(Vec3d(0., 0., (M_PI/180.) * dynamic_cast<const ConfigOptionFloat*>(proj_cfg.option("wipe_tower_rotation_angle"))->value));
|
|
||||||
set_flattening_data(nullptr);
|
|
||||||
set_sla_support_data(nullptr);
|
|
||||||
set_brim_data(nullptr);
|
|
||||||
set_painter_gizmo_data();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
set_scale(Vec3d::Ones());
|
|
||||||
set_rotation(Vec3d::Zero());
|
|
||||||
set_flattening_data(selection.is_from_single_object() ? selection.get_model()->objects[selection.get_object_idx()] : nullptr);
|
|
||||||
set_sla_support_data(selection.is_from_single_instance() ? selection.get_model()->objects[selection.get_object_idx()] : nullptr);
|
|
||||||
set_brim_data(selection.is_from_single_instance() ? selection.get_model()->objects[selection.get_object_idx()] : nullptr);
|
|
||||||
set_painter_gizmo_data();
|
|
||||||
}
|
|
||||||
|
|
||||||
//BBS: GUI refactor: add object manipulation in gizmo
|
//BBS: GUI refactor: add object manipulation in gizmo
|
||||||
if (!selection.is_empty()) {
|
if (m_current == EType::Move || m_current == EType::Rotate || m_current == EType::Scale) {
|
||||||
m_object_manipulation.update_ui_from_settings();
|
if (!selection.is_empty()) {
|
||||||
m_object_manipulation.UpdateAndShow(true);
|
m_object_manipulation.update_ui_from_settings();
|
||||||
|
m_object_manipulation.UpdateAndShow(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,12 +581,6 @@ void GLGizmosManager::set_rotation(const Vec3d& rotation)
|
|||||||
dynamic_cast<GLGizmoRotate3D*>(m_gizmos[Rotate].get())->set_rotation(rotation);
|
dynamic_cast<GLGizmoRotate3D*>(m_gizmos[Rotate].get())->set_rotation(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BBS
|
|
||||||
void GLGizmosManager::finish_cut_rotation()
|
|
||||||
{
|
|
||||||
dynamic_cast<GLGizmoAdvancedCut*>(m_gizmos[Cut].get())->finish_rotation();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmosManager::update_paint_base_camera_rotate_rad()
|
void GLGizmosManager::update_paint_base_camera_rotate_rad()
|
||||||
{
|
{
|
||||||
if (m_current == MmuSegmentation || m_current == Seam) {
|
if (m_current == MmuSegmentation || m_current == Seam) {
|
||||||
@ -671,45 +597,6 @@ Vec3d GLGizmosManager::get_flattening_normal() const
|
|||||||
return dynamic_cast<GLGizmoFlatten*>(m_gizmos[Flatten].get())->get_flattening_normal();
|
return dynamic_cast<GLGizmoFlatten*>(m_gizmos[Flatten].get())->get_flattening_normal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmosManager::set_flattening_data(const ModelObject* model_object)
|
|
||||||
{
|
|
||||||
if (!m_enabled || m_gizmos.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
dynamic_cast<GLGizmoFlatten*>(m_gizmos[Flatten].get())->set_flattening_data(model_object);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmosManager::set_sla_support_data(ModelObject* model_object)
|
|
||||||
{
|
|
||||||
if (! m_enabled
|
|
||||||
|| m_gizmos.empty()
|
|
||||||
|| wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto* gizmo_hollow = dynamic_cast<GLGizmoHollow*>(m_gizmos[Hollow].get());
|
|
||||||
auto* gizmo_supports = dynamic_cast<GLGizmoSlaSupports*>(m_gizmos[SlaSupports].get());
|
|
||||||
gizmo_hollow->set_sla_support_data(model_object, m_parent.get_selection());
|
|
||||||
gizmo_supports->set_sla_support_data(model_object, m_parent.get_selection());
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmosManager::set_brim_data(ModelObject* model_object)
|
|
||||||
{
|
|
||||||
if (!m_enabled || m_gizmos.empty())
|
|
||||||
return;
|
|
||||||
auto* gizmo_brim = dynamic_cast<GLGizmoBrimEars*>(m_gizmos[BrimEars].get());
|
|
||||||
gizmo_brim->set_brim_data(model_object, m_parent.get_selection());
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLGizmosManager::set_painter_gizmo_data()
|
|
||||||
{
|
|
||||||
if (!m_enabled || m_gizmos.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
dynamic_cast<GLGizmoFdmSupports*>(m_gizmos[FdmSupports].get())->set_painter_gizmo_data(m_parent.get_selection());
|
|
||||||
dynamic_cast<GLGizmoSeam*>(m_gizmos[Seam].get())->set_painter_gizmo_data(m_parent.get_selection());
|
|
||||||
dynamic_cast<GLGizmoMmuSegmentation*>(m_gizmos[MmuSegmentation].get())->set_painter_gizmo_data(m_parent.get_selection());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GLGizmosManager::is_gizmo_activable_when_single_full_instance() {
|
bool GLGizmosManager::is_gizmo_activable_when_single_full_instance() {
|
||||||
if (get_current_type() == GLGizmosManager::EType::Flatten ||
|
if (get_current_type() == GLGizmosManager::EType::Flatten ||
|
||||||
get_current_type() == GLGizmosManager::EType::Cut ||
|
get_current_type() == GLGizmosManager::EType::Cut ||
|
||||||
@ -1157,7 +1044,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||||||
processed = true;
|
processed = true;
|
||||||
else if (!selection.is_empty() && grabber_contains_mouse()) {
|
else if (!selection.is_empty() && grabber_contains_mouse()) {
|
||||||
if (!(m_current == Measure || m_current == Assembly)) {
|
if (!(m_current == Measure || m_current == Assembly)) {
|
||||||
update_data();
|
|
||||||
selection.start_dragging();
|
selection.start_dragging();
|
||||||
start_dragging();
|
start_dragging();
|
||||||
|
|
||||||
|
@ -240,7 +240,6 @@ public:
|
|||||||
bool check_gizmos_closed_except(EType) const;
|
bool check_gizmos_closed_except(EType) const;
|
||||||
|
|
||||||
void set_hover_id(int id);
|
void set_hover_id(int id);
|
||||||
void enable_grabber(EType type, unsigned int id, bool enable);
|
|
||||||
|
|
||||||
void update(const Linef3& mouse_ray, const Point& mouse_pos);
|
void update(const Linef3& mouse_ray, const Point& mouse_pos);
|
||||||
void update_data();
|
void update_data();
|
||||||
@ -268,9 +267,6 @@ public:
|
|||||||
Vec3d get_rotation() const;
|
Vec3d get_rotation() const;
|
||||||
void set_rotation(const Vec3d& rotation);
|
void set_rotation(const Vec3d& rotation);
|
||||||
|
|
||||||
// BBS
|
|
||||||
void finish_cut_rotation();
|
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
void* get_icon_texture_id(MENU_ICON_NAME icon) {
|
void* get_icon_texture_id(MENU_ICON_NAME icon) {
|
||||||
if (icon_list.find((int)icon) != icon_list.end())
|
if (icon_list.find((int)icon) != icon_list.end())
|
||||||
@ -287,14 +283,6 @@ public:
|
|||||||
void update_paint_base_camera_rotate_rad();
|
void update_paint_base_camera_rotate_rad();
|
||||||
Vec3d get_flattening_normal() const;
|
Vec3d get_flattening_normal() const;
|
||||||
|
|
||||||
void set_flattening_data(const ModelObject* model_object);
|
|
||||||
|
|
||||||
void set_sla_support_data(ModelObject* model_object);
|
|
||||||
|
|
||||||
void set_brim_data(ModelObject* model_object);
|
|
||||||
|
|
||||||
void set_painter_gizmo_data();
|
|
||||||
|
|
||||||
bool is_gizmo_activable_when_single_full_instance();
|
bool is_gizmo_activable_when_single_full_instance();
|
||||||
bool is_gizmo_click_empty_not_exit();
|
bool is_gizmo_click_empty_not_exit();
|
||||||
bool is_show_only_active_plate();
|
bool is_show_only_active_plate();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user