Fixed synchronization between Objects List and Object manipulator table
This commit is contained in:
parent
a32839260f
commit
1c0bc8a5f3
@ -1617,6 +1617,11 @@ void GLCanvas3D::Selection::clear()
|
|||||||
|
|
||||||
_update_type();
|
_update_type();
|
||||||
m_bounding_box_dirty = true;
|
m_bounding_box_dirty = true;
|
||||||
|
|
||||||
|
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
|
// resets the cache in the sidebar
|
||||||
|
wxGetApp().obj_manipul()->reset_cache();
|
||||||
|
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the selection based on the map from old indices to new indices after m_volumes changed.
|
// Update the selection based on the map from old indices to new indices after m_volumes changed.
|
||||||
|
@ -23,6 +23,14 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
m_og->set_grid_vgap(5);
|
m_og->set_grid_vgap(5);
|
||||||
|
|
||||||
m_og->m_on_change = [this](const std::string& opt_key, const boost::any& value) {
|
m_og->m_on_change = [this](const std::string& opt_key, const boost::any& value) {
|
||||||
|
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
|
// needed to hide the visual hints in 3D scene
|
||||||
|
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, false);
|
||||||
|
|
||||||
|
if (!m_cache.is_valid())
|
||||||
|
return;
|
||||||
|
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
|
|
||||||
std::vector<std::string> axes{ "_x", "_y", "_z" };
|
std::vector<std::string> axes{ "_x", "_y", "_z" };
|
||||||
|
|
||||||
std::string param;
|
std::string param;
|
||||||
@ -38,26 +46,26 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
else if (param == "rotation")
|
else if (param == "rotation")
|
||||||
change_rotation_value(new_value);
|
change_rotation_value(new_value);
|
||||||
else if (param == "scale")
|
else if (param == "scale")
|
||||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
change_scale_value(new_value);
|
change_scale_value(new_value);
|
||||||
#else
|
|
||||||
change_scale_value(new_value);
|
|
||||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
else if (param == "size")
|
else if (param == "size")
|
||||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
change_size_value(new_value);
|
change_size_value(new_value);
|
||||||
#else
|
|
||||||
change_size_value(new_value);
|
|
||||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
|
|
||||||
|
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, false);
|
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, false);
|
||||||
|
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
};
|
};
|
||||||
|
|
||||||
m_og->m_fill_empty_value = [this](const std::string& opt_key)
|
m_og->m_fill_empty_value = [this](const std::string& opt_key)
|
||||||
{
|
{
|
||||||
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
|
// needed to hide the visual hints in 3D scene
|
||||||
|
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, false);
|
||||||
|
|
||||||
|
if (!m_cache.is_valid())
|
||||||
|
return;
|
||||||
|
#else
|
||||||
this->update_if_dirty();
|
this->update_if_dirty();
|
||||||
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
|
|
||||||
std::string param;
|
std::string param;
|
||||||
std::copy(opt_key.begin(), opt_key.end() - 2, std::back_inserter(param));
|
std::copy(opt_key.begin(), opt_key.end() - 2, std::back_inserter(param));
|
||||||
@ -68,45 +76,31 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
int axis = opt_key.back() == 'x' ? 0 :
|
int axis = opt_key.back() == 'x' ? 0 :
|
||||||
opt_key.back() == 'y' ? 1 : 2;
|
opt_key.back() == 'y' ? 1 : 2;
|
||||||
|
|
||||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
value = m_cache.position(axis);
|
value = m_cache.position(axis);
|
||||||
#else
|
|
||||||
value = m_cache_position(axis);
|
|
||||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
}
|
}
|
||||||
else if (param == "rotation") {
|
else if (param == "rotation") {
|
||||||
int axis = opt_key.back() == 'x' ? 0 :
|
int axis = opt_key.back() == 'x' ? 0 :
|
||||||
opt_key.back() == 'y' ? 1 : 2;
|
opt_key.back() == 'y' ? 1 : 2;
|
||||||
|
|
||||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
value = m_cache.rotation(axis);
|
value = m_cache.rotation(axis);
|
||||||
#else
|
|
||||||
value = m_cache_rotation(axis);
|
|
||||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
}
|
}
|
||||||
else if (param == "scale") {
|
else if (param == "scale") {
|
||||||
int axis = opt_key.back() == 'x' ? 0 :
|
int axis = opt_key.back() == 'x' ? 0 :
|
||||||
opt_key.back() == 'y' ? 1 : 2;
|
opt_key.back() == 'y' ? 1 : 2;
|
||||||
|
|
||||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
value = m_cache.scale(axis);
|
value = m_cache.scale(axis);
|
||||||
#else
|
|
||||||
value = m_cache_scale(axis);
|
|
||||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
}
|
}
|
||||||
else if (param == "size") {
|
else if (param == "size") {
|
||||||
int axis = opt_key.back() == 'x' ? 0 :
|
int axis = opt_key.back() == 'x' ? 0 :
|
||||||
opt_key.back() == 'y' ? 1 : 2;
|
opt_key.back() == 'y' ? 1 : 2;
|
||||||
|
|
||||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
value = m_cache.size(axis);
|
value = m_cache.size(axis);
|
||||||
#else
|
|
||||||
value = m_cache_size(axis);
|
|
||||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_og->set_value(opt_key, double_to_string(value));
|
m_og->set_value(opt_key, double_to_string(value));
|
||||||
|
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, false);
|
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, false);
|
||||||
|
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
};
|
};
|
||||||
|
|
||||||
m_og->m_set_focus = [this](const std::string& opt_key)
|
m_og->m_set_focus = [this](const std::string& opt_key)
|
||||||
@ -114,6 +108,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
this->update_if_dirty();
|
this->update_if_dirty();
|
||||||
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
|
// needed to show the visual hints in 3D scene
|
||||||
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, true);
|
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -459,18 +454,10 @@ void ObjectManipulation::change_position_value(const Vec3d& position)
|
|||||||
auto canvas = wxGetApp().plater()->canvas3D();
|
auto canvas = wxGetApp().plater()->canvas3D();
|
||||||
GLCanvas3D::Selection& selection = canvas->get_selection();
|
GLCanvas3D::Selection& selection = canvas->get_selection();
|
||||||
selection.start_dragging();
|
selection.start_dragging();
|
||||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
selection.translate(position - m_cache.position, selection.requires_local_axes());
|
selection.translate(position - m_cache.position, selection.requires_local_axes());
|
||||||
#else
|
|
||||||
selection.translate(position - m_cache_position, selection.requires_local_axes());
|
|
||||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
canvas->do_move();
|
canvas->do_move();
|
||||||
|
|
||||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
m_cache.position = position;
|
m_cache.position = position;
|
||||||
#else
|
|
||||||
m_cache_position = position;
|
|
||||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::change_rotation_value(const Vec3d& rotation)
|
void ObjectManipulation::change_rotation_value(const Vec3d& rotation)
|
||||||
@ -503,11 +490,7 @@ void ObjectManipulation::change_scale_value(const Vec3d& scale)
|
|||||||
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||||
if (m_uniform_scale || selection.requires_uniform_scale())
|
if (m_uniform_scale || selection.requires_uniform_scale())
|
||||||
{
|
{
|
||||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
Vec3d abs_scale_diff = (scale - m_cache.scale).cwiseAbs();
|
Vec3d abs_scale_diff = (scale - m_cache.scale).cwiseAbs();
|
||||||
#else
|
|
||||||
Vec3d abs_scale_diff = (scale - m_cache_scale).cwiseAbs();
|
|
||||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
|
||||||
double max_diff = abs_scale_diff(X);
|
double max_diff = abs_scale_diff(X);
|
||||||
Axis max_diff_axis = X;
|
Axis max_diff_axis = X;
|
||||||
if (max_diff < abs_scale_diff(Y))
|
if (max_diff < abs_scale_diff(Y))
|
||||||
|
@ -43,11 +43,19 @@ class ObjectManipulation : public OG_Settings
|
|||||||
|
|
||||||
Instance instance;
|
Instance instance;
|
||||||
|
|
||||||
Cache() : position(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX)) , rotation(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX))
|
Cache() { reset(); }
|
||||||
, scale(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX)) , size(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX))
|
void reset()
|
||||||
, move_label_string("") , rotate_label_string("") , scale_label_string("")
|
|
||||||
{
|
{
|
||||||
|
position = Vec3d(DBL_MAX, DBL_MAX, DBL_MAX);
|
||||||
|
rotation = Vec3d(DBL_MAX, DBL_MAX, DBL_MAX);
|
||||||
|
scale = Vec3d(DBL_MAX, DBL_MAX, DBL_MAX);
|
||||||
|
size = Vec3d(DBL_MAX, DBL_MAX, DBL_MAX);
|
||||||
|
move_label_string = "";
|
||||||
|
rotate_label_string = "";
|
||||||
|
scale_label_string = "";
|
||||||
|
instance.reset();
|
||||||
}
|
}
|
||||||
|
bool is_valid() const { return position != Vec3d(DBL_MAX, DBL_MAX, DBL_MAX); }
|
||||||
};
|
};
|
||||||
|
|
||||||
Cache m_cache;
|
Cache m_cache;
|
||||||
@ -92,6 +100,10 @@ public:
|
|||||||
void set_uniform_scaling(const bool uniform_scale) { m_uniform_scale = uniform_scale;}
|
void set_uniform_scaling(const bool uniform_scale) { m_uniform_scale = uniform_scale;}
|
||||||
bool get_uniform_scaling() const { return m_uniform_scale; }
|
bool get_uniform_scaling() const { return m_uniform_scale; }
|
||||||
|
|
||||||
|
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
|
void reset_cache() { m_cache.reset(); }
|
||||||
|
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reset_settings_value();
|
void reset_settings_value();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user