@@ -2339,6 +2339,23 @@ void GLCanvas3D::zoom_to_plate(int plate_idx)
23392339 }
23402340}
23412341
2342+ void GLCanvas3D::zoom_to_fit()
2343+ {
2344+ if (!can_show_3d_navigator())
2345+ return;
2346+
2347+ select_view("plate");
2348+ if (m_selection.is_empty()) {
2349+ if (m_canvas_type == ECanvasType::CanvasAssembleView)
2350+ zoom_to_volumes();
2351+ else
2352+ zoom_to_bed();
2353+ }
2354+ else {
2355+ zoom_to_selection();
2356+ }
2357+ }
2358+
23422359void GLCanvas3D::select_view(const std::string& direction)
23432360{
23442361 get_active_camera().select_view(direction);
@@ -4304,18 +4321,6 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
43044321 break;
43054322 }
43064323#endif // ENABLE_RENDER_PICKING_PASS
4307- //case 'Z':
4308- //case 'z': {
4309- // if (!m_selection.is_empty())
4310- // zoom_to_selection();
4311- // else {
4312- // if (!m_volumes.empty())
4313- // zoom_to_volumes();
4314- // else
4315- // _zoom_to_box(m_gcode_viewer.get_paths_bounding_box());
4316- // }
4317- // break;
4318- //}
43194324 default: { evt.Skip(); break; }
43204325 }
43214326 }
@@ -9544,18 +9549,7 @@ void GLCanvas3D::_render_fit_camera_toolbar()
95449549
95459550 if (ImGui::ImageButton3(normal_id, hover_id, button_icon_size, ImVec2(0, 0), ImVec2(1, 1), -1,
95469551 ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1), ImVec2(10, 0))) {
9547- select_view("plate");
9548- if (m_selection.is_empty()) {
9549- if (m_canvas_type == ECanvasType::CanvasAssembleView) {
9550- zoom_to_volumes();
9551- }
9552- else {
9553- zoom_to_bed();
9554- }
9555- }
9556- else {
9557- zoom_to_selection();
9558- }
9552+ zoom_to_fit();
95599553 }
95609554 if (ImGui::IsItemHovered()) {
95619555 auto temp_tooltip = _L("Fit camera to scene or selected object.");
0 commit comments