FIX:all grabber should use GrabberSizeFactor

jira: none
Change-Id: I24629891a31e711097a8456291c5a5c3b606545f
This commit is contained in:
zhou.xu 2024-10-21 10:23:00 +08:00 committed by Lane.Wei
parent beb3241c96
commit 993e2a24c1
8 changed files with 36 additions and 45 deletions

View File

@ -715,11 +715,6 @@ void GLGizmoAdvancedCut::on_render_for_picking()
GLGizmoRotate3D::on_render_for_picking();
BoundingBoxf3 box = m_parent.get_selection().get_bounding_box();
#if ENABLE_FIXED_GRABBER
float mean_size = (float) (GLGizmoBase::Grabber::FixedGrabberSize);
#else
float mean_size = (float) ((box.size().x() + box.size().y() + box.size().z()) / 3.0);
#endif
// pick grabber
{
color = picking_color_component(0);
@ -727,14 +722,14 @@ void GLGizmoAdvancedCut::on_render_for_picking()
m_move_z_grabber.color[1] = color[1];
m_move_z_grabber.color[2] = color[2];
m_move_z_grabber.color[3] = color[3];
m_move_z_grabber.render_for_picking(mean_size);
m_move_z_grabber.render_for_picking();
if (m_cut_mode == CutMode::cutTongueAndGroove) {
color = picking_color_component(1);
m_move_x_grabber.color[0] = color[0];
m_move_x_grabber.color[1] = color[1];
m_move_x_grabber.color[2] = color[2];
m_move_x_grabber.color[3] = color[3];
m_move_x_grabber.render_for_picking(mean_size);
m_move_x_grabber.render_for_picking();
}
}
@ -1209,8 +1204,8 @@ void GLGizmoAdvancedCut::render_cut_plane_and_grabbers()
// BBS set to fixed size grabber
// float fullsize = 2 * (dragging ? get_dragging_half_size(size) : get_half_size(size));
float fullsize = 8.0f;
if (GLGizmoBase::INV_ZOOM > 0) { fullsize = m_move_z_grabber.FixedGrabberSize * GLGizmoBase::INV_ZOOM; }
float fullsize = get_grabber_size();
GLModel &cube_z = m_move_z_grabber.get_cube();
GLModel &cube_x = m_move_x_grabber.get_cube();
if (is_render_z_grabber) {

View File

@ -79,7 +79,7 @@ GLGizmoBase::Grabber::Grabber()
hover_color = GRABBER_HOVER_COL;
}
void GLGizmoBase::Grabber::render(bool hover, float size) const
void GLGizmoBase::Grabber::render(bool hover) const
{
std::array<float, 4> render_color;
if (hover) {
@ -88,7 +88,7 @@ void GLGizmoBase::Grabber::render(bool hover, float size) const
else
render_color = color;
render(size, render_color, false);
render(render_color, false);
}
float GLGizmoBase::Grabber::get_half_size(float size) const
@ -114,7 +114,7 @@ GLModel& GLGizmoBase::Grabber::get_cube()
return cube;
}
void GLGizmoBase::Grabber::render(float size, const std::array<float, 4>& render_color, bool picking) const
void GLGizmoBase::Grabber::render(const std::array<float, 4>& render_color, bool picking) const
{
if (! cube_initialized) {
// This cannot be done in constructor, OpenGL is not yet
@ -127,11 +127,7 @@ void GLGizmoBase::Grabber::render(float size, const std::array<float, 4>& render
//BBS set to fixed size grabber
//float fullsize = 2 * (dragging ? get_dragging_half_size(size) : get_half_size(size));
float fullsize = 8.0f;
if (GLGizmoBase::INV_ZOOM > 0) {
fullsize = FixedGrabberSize * GLGizmoBase::INV_ZOOM;
}
fullsize = fullsize * Grabber::GrabberSizeFactor;
float fullsize = get_grabber_size();
const_cast<GLModel*>(&cube)->set_color(-1, render_color);
@ -256,6 +252,16 @@ void GLGizmoBase::render_cross_mark(const Vec3f &target, bool is_single)
glsafe(::glEnd());
}
float GLGizmoBase::get_grabber_size()
{
float grabber_size = 8.0f;
if (GLGizmoBase::INV_ZOOM > 0) {
grabber_size = GLGizmoBase::Grabber::FixedGrabberSize * GLGizmoBase::INV_ZOOM;
grabber_size = grabber_size * GLGizmoBase::Grabber::GrabberSizeFactor;
}
return grabber_size;
}
GLGizmoBase::GLGizmoBase(GLCanvas3D &parent, const std::string &icon_filename, unsigned int sprite_id)
: m_parent(parent)
, m_group_id(-1)
@ -435,13 +441,13 @@ std::array<float, 4> GLGizmoBase::picking_color_component(unsigned int id) const
void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const
{
#if ENABLE_FIXED_GRABBER
render_grabbers((float)(GLGizmoBase::Grabber::FixedGrabberSize));
render_grabbers();
#else
render_grabbers((float)((box.size().x() + box.size().y() + box.size().z()) / 3.0));
#endif
}
void GLGizmoBase::render_grabbers(float size) const
void GLGizmoBase::render_grabbers() const
{
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
if (shader == nullptr)
@ -450,24 +456,18 @@ void GLGizmoBase::render_grabbers(float size) const
shader->set_uniform("emission_factor", 0.1f);
for (int i = 0; i < (int)m_grabbers.size(); ++i) {
if (m_grabbers[i].enabled)
m_grabbers[i].render(m_hover_id == i, size);
m_grabbers[i].render(m_hover_id == i);
}
shader->stop_using();
}
void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
{
#if ENABLE_FIXED_GRABBER
float mean_size = (float)(GLGizmoBase::Grabber::FixedGrabberSize);
#else
float mean_size = (float)((box.size().x() + box.size().y() + box.size().z()) / 3.0);
#endif
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i) {
if (m_grabbers[i].enabled) {
std::array<float, 4> color = picking_color_component(i);
m_grabbers[i].color = color;
m_grabbers[i].render_for_picking(mean_size);
m_grabbers[i].render_for_picking();
}
}
}

View File

@ -79,15 +79,15 @@ public:
Grabber();
void render(bool hover, float size) const;
void render_for_picking(float size) const { render(size, color, true); }
void render(bool hover) const;
void render_for_picking() const { render(color, true); }
float get_half_size(float size) const;
float get_dragging_half_size(float size) const;
GLModel& get_cube();
private:
void render(float size, const std::array<float, 4>& render_color, bool picking) const;
void render(const std::array<float, 4>& render_color, bool picking) const;
GLModel cube;
bool cube_initialized = false;
@ -173,6 +173,8 @@ protected:
bool render_combo(const std::string &label, const std::vector<std::string> &lines,
size_t &selection_idx, float label_width, float item_width);
void render_cross_mark(const Vec3f& target,bool is_single =false);
static float get_grabber_size();
public:
GLGizmoBase(GLCanvas3D& parent,
const std::string& icon_filename,
@ -268,7 +270,7 @@ protected:
// No check is made for clashing with other picking color (i.e. GLVolumes)
std::array<float, 4> picking_color_component(unsigned int id) const;
void render_grabbers(const BoundingBoxf3& box) const;
void render_grabbers(float size) const;
void render_grabbers() const;
void render_grabbers_for_picking(const BoundingBoxf3& box) const;
std::string format(float value, unsigned int decimals) const;

View File

@ -262,8 +262,8 @@ double GLGizmoMove3D::calc_projection(const UpdateData& data) const
void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking) const
{
double size = 0.75 * GLGizmoBase::Grabber::FixedGrabberSize * GLGizmoBase::INV_ZOOM;
size = size * GLGizmoBase::Grabber::GrabberSizeFactor;
double size = get_grabber_size() * 0.75;//0.75 for arrow show
std::array<float, 4> color = m_grabbers[axis].color;
if (!picking && m_hover_id != -1) {
if (m_hover_id == axis) {

View File

@ -314,8 +314,7 @@ void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const
void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool picking) const
{
double size = 0.75 * GLGizmoBase::Grabber::FixedGrabberSize * GLGizmoBase::INV_ZOOM;
size = size * GLGizmoBase::Grabber::GrabberSizeFactor;
double size = get_grabber_size() * 0.75;//0.75 for arrow show
std::array<float, 4> color = m_grabbers[0].color;
if (!picking && m_hover_id != -1) {

View File

@ -601,8 +601,7 @@ void GLGizmoSVG::on_render()
render_color = SVG_Move_GrabberHoverColor;
} else
render_color = SVG_Move_GrabberColor;
float fullsize = 8.0f;
if (GLGizmoBase::INV_ZOOM > 0) { fullsize = m_move_grabber.FixedGrabberSize * GLGizmoBase::INV_ZOOM; }
float fullsize = get_grabber_size();
m_move_grabber.center = tran.get_offset();
Transform3d rotate_matrix = tran.get_rotation_matrix();
Transform3d cube_mat = Geometry::translation_transform(m_move_grabber.center) * rotate_matrix * Geometry::scale_transform(fullsize);
@ -633,8 +632,7 @@ void GLGizmoSVG::on_render_for_picking()
m_move_grabber.color[1] = color[1];
m_move_grabber.color[2] = color[2];
m_move_grabber.color[3] = color[3];
float mean_size = (float) (GLGizmoBase::Grabber::FixedGrabberSize);
m_move_grabber.render_for_picking(mean_size);
m_move_grabber.render_for_picking();
}
//BBS: add input window for move

View File

@ -250,7 +250,6 @@ void GLGizmoScale3D::on_render()
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
float grabber_mean_size = (float) ((m_bounding_box.size().x() + m_bounding_box.size().y() + m_bounding_box.size().z()) / 3.0);
glsafe(::glPushMatrix());
glsafe(::glMultMatrixd(m_grabbers_tran.get_matrix().data()));
//draw connections
@ -272,7 +271,7 @@ void GLGizmoScale3D::on_render()
render_grabbers_connection(9, 6);
// draw grabbers
render_grabbers(grabber_mean_size);
render_grabbers();
glsafe(::glPopMatrix());
}

View File

@ -596,8 +596,7 @@ void GLGizmoText::on_render()
render_color = TEXT_GRABBER_HOVER_COLOR;
} else
render_color = TEXT_GRABBER_COLOR;
float fullsize = 8.0f;
if (GLGizmoBase::INV_ZOOM > 0) { fullsize = m_move_grabber.FixedGrabberSize * GLGizmoBase::INV_ZOOM; }
float fullsize = get_grabber_size();
m_move_grabber.center = tran.get_offset();
Transform3d rotate_matrix = tran.get_rotation_matrix();
Transform3d cube_mat = Geometry::translation_transform(m_move_grabber.center) * rotate_matrix * Geometry::scale_transform(fullsize);
@ -629,8 +628,7 @@ void GLGizmoText::on_render_for_picking()
m_move_grabber.color[1] = color[1];
m_move_grabber.color[2] = color[2];
m_move_grabber.color[3] = color[3];
float mean_size = (float) (GLGizmoBase::Grabber::FixedGrabberSize);
m_move_grabber.render_for_picking(mean_size);
m_move_grabber.render_for_picking();
}
}