mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-16 19:11:50 +08:00
Tech ENABLE_WORLD_COORDINATE - Resize Move and Rotate gizmos in dependence of the selected coordinate system
This commit is contained in:
parent
b754ee3c84
commit
e1619944ad
@ -110,8 +110,17 @@ void GLGizmoMove3D::on_render()
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
const Selection& selection = m_parent.get_selection();
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
#if ENABLE_WORLD_COORDINATE
|
||||
BoundingBoxf3 box;
|
||||
if (wxGetApp().obj_manipul()->get_world_coordinates())
|
||||
box = selection.get_bounding_box();
|
||||
else {
|
||||
const Selection::IndicesList& ids = selection.get_volume_idxs();
|
||||
for (unsigned int id : ids) {
|
||||
const GLVolume* v = selection.get_volume(id);
|
||||
box.merge(v->transformed_convex_hull_bounding_box(v->get_volume_transformation().get_matrix()));
|
||||
}
|
||||
}
|
||||
glsafe(::glPushMatrix());
|
||||
transform_to_local(selection);
|
||||
|
||||
@ -130,6 +139,7 @@ void GLGizmoMove3D::on_render()
|
||||
m_grabbers[2].center = { 0.0, 0.0, half_box_size.z() + Offset };
|
||||
m_grabbers[2].color = AXES_COLOR[2];
|
||||
#else
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
const Vec3d& center = box.center();
|
||||
|
||||
// x axis
|
||||
|
@ -45,6 +45,10 @@ GLGizmoRotate::GLGizmoRotate(const GLGizmoRotate& other)
|
||||
, m_snap_coarse_out_radius(other.m_snap_coarse_out_radius)
|
||||
, m_snap_fine_in_radius(other.m_snap_fine_in_radius)
|
||||
, m_snap_fine_out_radius(other.m_snap_fine_out_radius)
|
||||
#if ENABLE_WORLD_COORDINATE
|
||||
, m_bounding_box(other.m_bounding_box)
|
||||
, m_orient_matrix(other.m_orient_matrix)
|
||||
#endif // ENABLE_WORLD_COORDINATE
|
||||
{
|
||||
}
|
||||
|
||||
@ -128,7 +132,9 @@ void GLGizmoRotate::on_render()
|
||||
return;
|
||||
|
||||
const Selection& selection = m_parent.get_selection();
|
||||
#if !ENABLE_WORLD_COORDINATE
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
#endif // !ENABLE_WORLD_COORDINATE
|
||||
|
||||
if (m_hover_id != 0 && !m_grabbers[0].dragging) {
|
||||
#if ENABLE_WORLD_COORDINATE
|
||||
@ -164,8 +170,13 @@ void GLGizmoRotate::on_render()
|
||||
if (m_hover_id != -1)
|
||||
render_angle();
|
||||
|
||||
#if ENABLE_WORLD_COORDINATE
|
||||
render_grabber(m_bounding_box);
|
||||
render_grabber_extension(m_bounding_box, false);
|
||||
#else
|
||||
render_grabber(box);
|
||||
render_grabber_extension(box, false);
|
||||
#endif // ENABLE_WORLD_COORDINATE
|
||||
|
||||
glsafe(::glPopMatrix());
|
||||
}
|
||||
@ -180,9 +191,14 @@ void GLGizmoRotate::on_render_for_picking()
|
||||
|
||||
transform_to_local(selection);
|
||||
|
||||
#if ENABLE_WORLD_COORDINATE
|
||||
render_grabbers_for_picking(m_bounding_box);
|
||||
render_grabber_extension(m_bounding_box, true);
|
||||
#else
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
render_grabbers_for_picking(box);
|
||||
render_grabber_extension(box, true);
|
||||
#endif // ENABLE_WORLD_COORDINATE
|
||||
|
||||
glsafe(::glPopMatrix());
|
||||
}
|
||||
@ -190,9 +206,26 @@ void GLGizmoRotate::on_render_for_picking()
|
||||
#if ENABLE_WORLD_COORDINATE
|
||||
void GLGizmoRotate::init_data_from_selection(const Selection& selection)
|
||||
{
|
||||
#if ENABLE_WORLD_COORDINATE
|
||||
m_bounding_box.reset();
|
||||
if (wxGetApp().obj_manipul()->get_world_coordinates()) {
|
||||
m_bounding_box = selection.get_bounding_box();
|
||||
m_center = m_bounding_box.center();
|
||||
}
|
||||
else {
|
||||
const Selection::IndicesList& ids = selection.get_volume_idxs();
|
||||
for (unsigned int id : ids) {
|
||||
const GLVolume* v = selection.get_volume(id);
|
||||
m_bounding_box.merge(v->transformed_convex_hull_bounding_box(v->get_volume_transformation().get_matrix()));
|
||||
}
|
||||
m_center = selection.get_volume(*ids.begin())->get_instance_transformation().get_matrix() * m_bounding_box.center();
|
||||
}
|
||||
m_radius = Offset + m_bounding_box.radius();
|
||||
#else
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
m_center = box.center();
|
||||
m_radius = Offset + box.radius();
|
||||
#endif // ENABLE_WORLD_COORDINATE
|
||||
m_snap_coarse_in_radius = m_radius / 3.0f;
|
||||
m_snap_coarse_out_radius = 2.0f * m_snap_coarse_in_radius;
|
||||
m_snap_fine_in_radius = m_radius;
|
||||
|
@ -38,6 +38,7 @@ private:
|
||||
float m_snap_fine_in_radius{ 0.0 };
|
||||
float m_snap_fine_out_radius{ 0.0 };
|
||||
#if ENABLE_WORLD_COORDINATE
|
||||
BoundingBoxf3 m_bounding_box;
|
||||
Transform3d m_orient_matrix{ Transform3d::Identity() };
|
||||
#endif // ENABLE_WORLD_COORDINATE
|
||||
|
||||
|
@ -1885,7 +1885,8 @@ void Selection::render_sidebar_position_hints(const std::string& sidebar_field)
|
||||
|
||||
void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field) const
|
||||
{
|
||||
auto render_sidebar_rotation_hint = [this]() {
|
||||
auto render_sidebar_rotation_hint = [this](const std::array<float, 4>& color) {
|
||||
const_cast<GLModel*>(&m_curved_arrow)->set_color(-1, color);
|
||||
m_curved_arrow.render();
|
||||
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
|
||||
m_curved_arrow.render();
|
||||
@ -1893,18 +1894,14 @@ void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field)
|
||||
|
||||
if (boost::ends_with(sidebar_field, "x")) {
|
||||
glsafe(::glRotated(90.0, 0.0, 1.0, 0.0));
|
||||
const_cast<GLModel*>(&m_curved_arrow)->set_color(-1, get_color(X));
|
||||
render_sidebar_rotation_hint();
|
||||
render_sidebar_rotation_hint(get_color(X));
|
||||
}
|
||||
else if (boost::ends_with(sidebar_field, "y")) {
|
||||
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
|
||||
const_cast<GLModel*>(&m_curved_arrow)->set_color(-1, get_color(Y));
|
||||
render_sidebar_rotation_hint();
|
||||
}
|
||||
else if (boost::ends_with(sidebar_field, "z")) {
|
||||
const_cast<GLModel*>(&m_curved_arrow)->set_color(-1, get_color(Z));
|
||||
render_sidebar_rotation_hint();
|
||||
render_sidebar_rotation_hint(get_color(Y));
|
||||
}
|
||||
else if (boost::ends_with(sidebar_field, "z"))
|
||||
render_sidebar_rotation_hint(get_color(Z));
|
||||
}
|
||||
|
||||
void Selection::render_sidebar_scale_hints(const std::string& sidebar_field) const
|
||||
@ -1977,10 +1974,10 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) co
|
||||
|
||||
const BoundingBoxf3& box = get_bounding_box();
|
||||
|
||||
const float min_x = box.min(0) - Margin;
|
||||
const float max_x = box.max(0) + Margin;
|
||||
const float min_y = box.min(1) - Margin;
|
||||
const float max_y = box.max(1) + Margin;
|
||||
const float min_x = box.min.x() - Margin;
|
||||
const float max_x = box.max.x() + Margin;
|
||||
const float min_y = box.min.y() - Margin;
|
||||
const float max_y = box.max.y() + Margin;
|
||||
|
||||
// view dependend order of rendering to keep correct transparency
|
||||
bool camera_on_top = wxGetApp().plater()->get_camera().is_looking_downward();
|
||||
|
Loading…
x
Reference in New Issue
Block a user