@@ -2254,6 +2254,23 @@ void GLCanvas3D::zoom_to_plate(int plate_idx)
22542254 }
22552255}
22562256
2257+ void GLCanvas3D::zoom_to_fit()
2258+ {
2259+ if (!can_show_3d_navigator())
2260+ return;
2261+
2262+ select_view("plate");
2263+ if (m_selection.is_empty()) {
2264+ if (m_canvas_type == ECanvasType::CanvasAssembleView)
2265+ zoom_to_volumes();
2266+ else
2267+ zoom_to_bed();
2268+ }
2269+ else {
2270+ zoom_to_selection();
2271+ }
2272+ }
2273+
22572274void GLCanvas3D::select_view(const std::string& direction)
22582275{
22592276 get_active_camera().select_view(direction);
@@ -4183,18 +4200,6 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
41834200 break;
41844201 }
41854202#endif // ENABLE_RENDER_PICKING_PASS
4186- //case 'Z':
4187- //case 'z': {
4188- // if (!m_selection.is_empty())
4189- // zoom_to_selection();
4190- // else {
4191- // if (!m_volumes.empty())
4192- // zoom_to_volumes();
4193- // else
4194- // _zoom_to_box(m_gcode_viewer.get_paths_bounding_box());
4195- // }
4196- // break;
4197- //}
41984203 default: { evt.Skip(); break; }
41994204 }
42004205 }
@@ -8883,18 +8888,7 @@ void GLCanvas3D::_render_fit_camera_toolbar()
88838888
88848889 if (ImGui::ImageButton3(normal_id, hover_id, button_icon_size, ImVec2(0, 0), ImVec2(1, 1), -1,
88858890 ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1), ImVec2(10, 0))) {
8886- select_view("plate");
8887- if (m_selection.is_empty()) {
8888- if (m_canvas_type == ECanvasType::CanvasAssembleView) {
8889- zoom_to_volumes();
8890- }
8891- else {
8892- zoom_to_bed();
8893- }
8894- }
8895- else {
8896- zoom_to_selection();
8897- }
8891+ zoom_to_fit();
88988892 }
88998893 if (ImGui::IsItemHovered()) {
89008894 auto temp_tooltip = _L("Fit camera to scene or selected object.");
0 commit comments