mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-01 06:41:42 -05:00
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>
30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
using System.Linq;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.Desktop.Interaction;
|
|
|
|
/// <summary>
|
|
/// The areas View > 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 > 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 > Plate: the sheet without its parts, or null.</summary>
|
|
public static Box PlateArea(Plate plate) => plate?.BoundingBox(false);
|
|
|
|
/// <summary>
|
|
/// Zoom To > 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();
|
|
}
|
|
}
|