Files
OpenNest/OpenNest.Desktop/Interaction/PlateZoom.cs
T
ajandClaude Opus 5.5 cf6a7df3be feat(desktop): share zoom window, measure area, hover tip and resize scaling
ZoomWindowTool and MeasureAreaTool port the WinForms Zoom Window and Select
Area actions onto the shared plate tool framework; PartHoverTip is the plate
view's delayed drawing-name tooltip; PlateZoom gives the Zoom To areas.
ViewTransform now scales with the viewport on resize as DrawControl does and
zooms about its center by the menu's 1.5 step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 20:09:17 -05:00

30 lines
1.1 KiB
C#

using System.Linq;
using OpenNest.Geometry;
namespace OpenNest.Desktop.Interaction;
/// <summary>
/// The areas View &gt; Zoom To fits, as the WinForms plate view's: Fit takes the plate with its
/// parts, Plate the sheet alone and Selected the selected parts.
/// </summary>
public static class PlateZoom
{
/// <summary>Zoom To &gt; Fit (and the F key): the plate and every part on it, or null.</summary>
public static Box FitArea(Plate plate) => plate?.BoundingBox(true);
/// <summary>Zoom To &gt; Plate: the sheet without its parts, or null.</summary>
public static Box PlateArea(Plate plate) => plate?.BoundingBox(false);
/// <summary>
/// Zoom To &gt; Selected: the selected parts on the plate (cut-offs left out, as WinForms),
/// or null when no part is selected.
/// </summary>
public static Box SelectedArea(Plate plate, PlateSelection selection)
{
if (plate == null || selection == null)
return null;
var parts = selection.Parts.Where(plate.Parts.Contains).ToList();
return parts.Count == 0 ? null : parts.GetBoundingBox();
}
}