FIX:all grabber should use GrabberSizeFactor
jira: none Change-Id: I24629891a31e711097a8456291c5a5c3b606545f
This commit is contained in:
parent
beb3241c96
commit
993e2a24c1
|
@ -715,11 +715,6 @@ void GLGizmoAdvancedCut::on_render_for_picking()
|
||||||
GLGizmoRotate3D::on_render_for_picking();
|
GLGizmoRotate3D::on_render_for_picking();
|
||||||
|
|
||||||
BoundingBoxf3 box = m_parent.get_selection().get_bounding_box();
|
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
|
// pick grabber
|
||||||
{
|
{
|
||||||
color = picking_color_component(0);
|
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[1] = color[1];
|
||||||
m_move_z_grabber.color[2] = color[2];
|
m_move_z_grabber.color[2] = color[2];
|
||||||
m_move_z_grabber.color[3] = color[3];
|
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) {
|
if (m_cut_mode == CutMode::cutTongueAndGroove) {
|
||||||
color = picking_color_component(1);
|
color = picking_color_component(1);
|
||||||
m_move_x_grabber.color[0] = color[0];
|
m_move_x_grabber.color[0] = color[0];
|
||||||
m_move_x_grabber.color[1] = color[1];
|
m_move_x_grabber.color[1] = color[1];
|
||||||
m_move_x_grabber.color[2] = color[2];
|
m_move_x_grabber.color[2] = color[2];
|
||||||
m_move_x_grabber.color[3] = color[3];
|
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
|
// BBS set to fixed size grabber
|
||||||
// float fullsize = 2 * (dragging ? get_dragging_half_size(size) : get_half_size(size));
|
// float fullsize = 2 * (dragging ? get_dragging_half_size(size) : get_half_size(size));
|
||||||
float fullsize = 8.0f;
|
float fullsize = get_grabber_size();
|
||||||
if (GLGizmoBase::INV_ZOOM > 0) { fullsize = m_move_z_grabber.FixedGrabberSize * GLGizmoBase::INV_ZOOM; }
|
|
||||||
GLModel &cube_z = m_move_z_grabber.get_cube();
|
GLModel &cube_z = m_move_z_grabber.get_cube();
|
||||||
GLModel &cube_x = m_move_x_grabber.get_cube();
|
GLModel &cube_x = m_move_x_grabber.get_cube();
|
||||||
if (is_render_z_grabber) {
|
if (is_render_z_grabber) {
|
||||||
|
|
|
@ -79,7 +79,7 @@ GLGizmoBase::Grabber::Grabber()
|
||||||
hover_color = GRABBER_HOVER_COL;
|
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;
|
std::array<float, 4> render_color;
|
||||||
if (hover) {
|
if (hover) {
|
||||||
|
@ -88,7 +88,7 @@ void GLGizmoBase::Grabber::render(bool hover, float size) const
|
||||||
else
|
else
|
||||||
render_color = color;
|
render_color = color;
|
||||||
|
|
||||||
render(size, render_color, false);
|
render(render_color, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLGizmoBase::Grabber::get_half_size(float size) const
|
float GLGizmoBase::Grabber::get_half_size(float size) const
|
||||||
|
@ -114,7 +114,7 @@ GLModel& GLGizmoBase::Grabber::get_cube()
|
||||||
return 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) {
|
if (! cube_initialized) {
|
||||||
// This cannot be done in constructor, OpenGL is not yet
|
// 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
|
//BBS set to fixed size grabber
|
||||||
//float fullsize = 2 * (dragging ? get_dragging_half_size(size) : get_half_size(size));
|
//float fullsize = 2 * (dragging ? get_dragging_half_size(size) : get_half_size(size));
|
||||||
float fullsize = 8.0f;
|
float fullsize = get_grabber_size();
|
||||||
if (GLGizmoBase::INV_ZOOM > 0) {
|
|
||||||
fullsize = FixedGrabberSize * GLGizmoBase::INV_ZOOM;
|
|
||||||
}
|
|
||||||
fullsize = fullsize * Grabber::GrabberSizeFactor;
|
|
||||||
|
|
||||||
const_cast<GLModel*>(&cube)->set_color(-1, render_color);
|
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());
|
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)
|
GLGizmoBase::GLGizmoBase(GLCanvas3D &parent, const std::string &icon_filename, unsigned int sprite_id)
|
||||||
: m_parent(parent)
|
: m_parent(parent)
|
||||||
, m_group_id(-1)
|
, 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
|
void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const
|
||||||
{
|
{
|
||||||
#if ENABLE_FIXED_GRABBER
|
#if ENABLE_FIXED_GRABBER
|
||||||
render_grabbers((float)(GLGizmoBase::Grabber::FixedGrabberSize));
|
render_grabbers();
|
||||||
#else
|
#else
|
||||||
render_grabbers((float)((box.size().x() + box.size().y() + box.size().z()) / 3.0));
|
render_grabbers((float)((box.size().x() + box.size().y() + box.size().z()) / 3.0));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoBase::render_grabbers(float size) const
|
void GLGizmoBase::render_grabbers() const
|
||||||
{
|
{
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
|
@ -450,24 +456,18 @@ void GLGizmoBase::render_grabbers(float size) const
|
||||||
shader->set_uniform("emission_factor", 0.1f);
|
shader->set_uniform("emission_factor", 0.1f);
|
||||||
for (int i = 0; i < (int)m_grabbers.size(); ++i) {
|
for (int i = 0; i < (int)m_grabbers.size(); ++i) {
|
||||||
if (m_grabbers[i].enabled)
|
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();
|
shader->stop_using();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
|
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) {
|
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i) {
|
||||||
if (m_grabbers[i].enabled) {
|
if (m_grabbers[i].enabled) {
|
||||||
std::array<float, 4> color = picking_color_component(i);
|
std::array<float, 4> color = picking_color_component(i);
|
||||||
m_grabbers[i].color = color;
|
m_grabbers[i].color = color;
|
||||||
m_grabbers[i].render_for_picking(mean_size);
|
m_grabbers[i].render_for_picking();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,15 +79,15 @@ public:
|
||||||
|
|
||||||
Grabber();
|
Grabber();
|
||||||
|
|
||||||
void render(bool hover, float size) const;
|
void render(bool hover) const;
|
||||||
void render_for_picking(float size) const { render(size, color, true); }
|
void render_for_picking() const { render(color, true); }
|
||||||
|
|
||||||
float get_half_size(float size) const;
|
float get_half_size(float size) const;
|
||||||
float get_dragging_half_size(float size) const;
|
float get_dragging_half_size(float size) const;
|
||||||
GLModel& get_cube();
|
GLModel& get_cube();
|
||||||
|
|
||||||
private:
|
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;
|
GLModel cube;
|
||||||
bool cube_initialized = false;
|
bool cube_initialized = false;
|
||||||
|
@ -173,6 +173,8 @@ protected:
|
||||||
bool render_combo(const std::string &label, const std::vector<std::string> &lines,
|
bool render_combo(const std::string &label, const std::vector<std::string> &lines,
|
||||||
size_t &selection_idx, float label_width, float item_width);
|
size_t &selection_idx, float label_width, float item_width);
|
||||||
void render_cross_mark(const Vec3f& target,bool is_single =false);
|
void render_cross_mark(const Vec3f& target,bool is_single =false);
|
||||||
|
static float get_grabber_size();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GLGizmoBase(GLCanvas3D& parent,
|
GLGizmoBase(GLCanvas3D& parent,
|
||||||
const std::string& icon_filename,
|
const std::string& icon_filename,
|
||||||
|
@ -268,7 +270,7 @@ protected:
|
||||||
// No check is made for clashing with other picking color (i.e. GLVolumes)
|
// No check is made for clashing with other picking color (i.e. GLVolumes)
|
||||||
std::array<float, 4> picking_color_component(unsigned int id) const;
|
std::array<float, 4> picking_color_component(unsigned int id) const;
|
||||||
void render_grabbers(const BoundingBoxf3& box) 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;
|
void render_grabbers_for_picking(const BoundingBoxf3& box) const;
|
||||||
|
|
||||||
std::string format(float value, unsigned int decimals) const;
|
std::string format(float value, unsigned int decimals) const;
|
||||||
|
|
|
@ -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
|
void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking) const
|
||||||
{
|
{
|
||||||
double size = 0.75 * GLGizmoBase::Grabber::FixedGrabberSize * GLGizmoBase::INV_ZOOM;
|
double size = get_grabber_size() * 0.75;//0.75 for arrow show
|
||||||
size = size * GLGizmoBase::Grabber::GrabberSizeFactor;
|
|
||||||
std::array<float, 4> color = m_grabbers[axis].color;
|
std::array<float, 4> color = m_grabbers[axis].color;
|
||||||
if (!picking && m_hover_id != -1) {
|
if (!picking && m_hover_id != -1) {
|
||||||
if (m_hover_id == axis) {
|
if (m_hover_id == axis) {
|
||||||
|
|
|
@ -314,8 +314,7 @@ void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const
|
||||||
|
|
||||||
void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool picking) const
|
void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool picking) const
|
||||||
{
|
{
|
||||||
double size = 0.75 * GLGizmoBase::Grabber::FixedGrabberSize * GLGizmoBase::INV_ZOOM;
|
double size = get_grabber_size() * 0.75;//0.75 for arrow show
|
||||||
size = size * GLGizmoBase::Grabber::GrabberSizeFactor;
|
|
||||||
|
|
||||||
std::array<float, 4> color = m_grabbers[0].color;
|
std::array<float, 4> color = m_grabbers[0].color;
|
||||||
if (!picking && m_hover_id != -1) {
|
if (!picking && m_hover_id != -1) {
|
||||||
|
|
|
@ -601,8 +601,7 @@ void GLGizmoSVG::on_render()
|
||||||
render_color = SVG_Move_GrabberHoverColor;
|
render_color = SVG_Move_GrabberHoverColor;
|
||||||
} else
|
} else
|
||||||
render_color = SVG_Move_GrabberColor;
|
render_color = SVG_Move_GrabberColor;
|
||||||
float fullsize = 8.0f;
|
float fullsize = get_grabber_size();
|
||||||
if (GLGizmoBase::INV_ZOOM > 0) { fullsize = m_move_grabber.FixedGrabberSize * GLGizmoBase::INV_ZOOM; }
|
|
||||||
m_move_grabber.center = tran.get_offset();
|
m_move_grabber.center = tran.get_offset();
|
||||||
Transform3d rotate_matrix = tran.get_rotation_matrix();
|
Transform3d rotate_matrix = tran.get_rotation_matrix();
|
||||||
Transform3d cube_mat = Geometry::translation_transform(m_move_grabber.center) * rotate_matrix * Geometry::scale_transform(fullsize);
|
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[1] = color[1];
|
||||||
m_move_grabber.color[2] = color[2];
|
m_move_grabber.color[2] = color[2];
|
||||||
m_move_grabber.color[3] = color[3];
|
m_move_grabber.color[3] = color[3];
|
||||||
float mean_size = (float) (GLGizmoBase::Grabber::FixedGrabberSize);
|
m_move_grabber.render_for_picking();
|
||||||
m_move_grabber.render_for_picking(mean_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//BBS: add input window for move
|
//BBS: add input window for move
|
||||||
|
|
|
@ -250,7 +250,6 @@ void GLGizmoScale3D::on_render()
|
||||||
|
|
||||||
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
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(::glPushMatrix());
|
||||||
glsafe(::glMultMatrixd(m_grabbers_tran.get_matrix().data()));
|
glsafe(::glMultMatrixd(m_grabbers_tran.get_matrix().data()));
|
||||||
//draw connections
|
//draw connections
|
||||||
|
@ -272,7 +271,7 @@ void GLGizmoScale3D::on_render()
|
||||||
render_grabbers_connection(9, 6);
|
render_grabbers_connection(9, 6);
|
||||||
|
|
||||||
// draw grabbers
|
// draw grabbers
|
||||||
render_grabbers(grabber_mean_size);
|
render_grabbers();
|
||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -596,8 +596,7 @@ void GLGizmoText::on_render()
|
||||||
render_color = TEXT_GRABBER_HOVER_COLOR;
|
render_color = TEXT_GRABBER_HOVER_COLOR;
|
||||||
} else
|
} else
|
||||||
render_color = TEXT_GRABBER_COLOR;
|
render_color = TEXT_GRABBER_COLOR;
|
||||||
float fullsize = 8.0f;
|
float fullsize = get_grabber_size();
|
||||||
if (GLGizmoBase::INV_ZOOM > 0) { fullsize = m_move_grabber.FixedGrabberSize * GLGizmoBase::INV_ZOOM; }
|
|
||||||
m_move_grabber.center = tran.get_offset();
|
m_move_grabber.center = tran.get_offset();
|
||||||
Transform3d rotate_matrix = tran.get_rotation_matrix();
|
Transform3d rotate_matrix = tran.get_rotation_matrix();
|
||||||
Transform3d cube_mat = Geometry::translation_transform(m_move_grabber.center) * rotate_matrix * Geometry::scale_transform(fullsize);
|
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[1] = color[1];
|
||||||
m_move_grabber.color[2] = color[2];
|
m_move_grabber.color[2] = color[2];
|
||||||
m_move_grabber.color[3] = color[3];
|
m_move_grabber.color[3] = color[3];
|
||||||
float mean_size = (float) (GLGizmoBase::Grabber::FixedGrabberSize);
|
m_move_grabber.render_for_picking();
|
||||||
m_move_grabber.render_for_picking(mean_size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue