FIX:limit scaling ratio by grabber in scale tool
jira: none Change-Id: I20a4404d4e4025ae230ab46ba8d8d3e5ffed10e3
This commit is contained in:
parent
e412fa3492
commit
97f63f167e
|
@ -29,7 +29,17 @@ GLGizmoScale3D::GLGizmoScale3D(GLCanvas3D& parent, const std::string& icon_filen
|
|||
, m_snap_step(0.05)
|
||||
//BBS: GUI refactor: add obj manipulation
|
||||
, m_object_manipulation(obj_manipulation)
|
||||
{}
|
||||
|
||||
const Vec3d &GLGizmoScale3D::get_scale()
|
||||
{
|
||||
if (m_object_manipulation) {
|
||||
Vec3d cache_scale = m_object_manipulation->get_cache().scale.cwiseQuotient(Vec3d(100,100,100));
|
||||
Vec3d temp_scale = cache_scale.cwiseProduct(m_scale);
|
||||
m_object_manipulation->limit_scaling_ratio(temp_scale);
|
||||
m_scale = temp_scale.cwiseQuotient(cache_scale);
|
||||
}
|
||||
return m_scale;
|
||||
}
|
||||
|
||||
std::string GLGizmoScale3D::get_tooltip() const
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
double get_snap_step(double step) const { return m_snap_step; }
|
||||
void set_snap_step(double step) { m_snap_step = step; }
|
||||
|
||||
const Vec3d& get_scale() const { return m_scale; }
|
||||
const Vec3d &get_scale();
|
||||
void set_scale(const Vec3d& scale) { m_starting.scale = scale; m_scale = scale; }
|
||||
|
||||
const Vec3d& get_offset() const { return m_offset; }
|
||||
|
|
|
@ -395,18 +395,23 @@ void GizmoObjectManipulation::do_scale(int axis, const Vec3d &scale) const
|
|||
transformation_type.set_relative();
|
||||
|
||||
Vec3d scaling_factor = m_uniform_scale ? scale(axis) * Vec3d::Ones() : scale;
|
||||
for (size_t i = 0; i < scaling_factor.size(); i++) {//range protect //scaling_factor too big has problem
|
||||
if (scaling_factor[i] * m_unscale_size[i] > MAX_NUM) {
|
||||
scaling_factor[i] = MAX_NUM/ m_unscale_size[i];
|
||||
}
|
||||
}
|
||||
limit_scaling_ratio(scaling_factor);
|
||||
|
||||
selection.start_dragging();
|
||||
selection.scale(scaling_factor, transformation_type);
|
||||
m_glcanvas.do_scale(L("Set Scale"));
|
||||
}
|
||||
|
||||
|
||||
void GizmoObjectManipulation::on_change(const std::string& opt_key, int axis, double new_value)
|
||||
void GizmoObjectManipulation::limit_scaling_ratio(Vec3d &scaling_factor) const{
|
||||
for (size_t i = 0; i < scaling_factor.size(); i++) { // range protect //scaling_factor too big has problem
|
||||
if (scaling_factor[i] * m_unscale_size[i] > MAX_NUM) {
|
||||
scaling_factor[i] = MAX_NUM / m_unscale_size[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GizmoObjectManipulation::on_change(const std::string &opt_key, int axis, double new_value)
|
||||
{
|
||||
if (!m_cache.is_valid())
|
||||
return;
|
||||
|
|
|
@ -117,8 +117,10 @@ public:
|
|||
bool is_instance_coordinates() const { return m_coordinates_type == ECoordinatesType::Instance; }
|
||||
bool is_local_coordinates() const { return m_coordinates_type == ECoordinatesType::Local; }
|
||||
|
||||
const Cache& get_cache() {return m_cache; }
|
||||
void reset_cache() { m_cache.reset(); }
|
||||
|
||||
void limit_scaling_ratio(Vec3d &scaling_factor) const;
|
||||
void on_change(const std::string& opt_key, int axis, double new_value);
|
||||
bool render_combo(ImGuiWrapper *imgui_wrapper, const std::string &label, const std::vector<std::string> &lines, size_t &selection_idx, float label_width, float item_width);
|
||||
void do_render_move_window(ImGuiWrapper *imgui_wrapper, std::string window_name, float x, float y, float bottom_limit);
|
||||
|
|
Loading…
Reference in New Issue