/// <summary> /// Sets the <see cref="ScanWindow"/>, in mill coordinates, within which a camera will look for the laser. Default is an /// unconstrained window. /// </summary> /// <remarks> /// The <see cref="ScanWindow"/> constraints are only sent to the scan head when <see cref="ScanSystem.Connect"/> is called. /// </remarks> /// <param name="window">The <see cref="ScanWindow"/> to use for the <see cref="ScanHead"/>.</param> /// <exception cref="Exception"> /// <see cref="IsConnected"/> is `true`. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="window"/> is null. /// </exception> public void SetWindow(ScanWindow window) { if (IsConnected) { throw new Exception("Can not set scan window while connected."); } if (window == null) { throw new ArgumentNullException(nameof(window)); } Window = (ScanWindow)window.Clone(); }
/// <summary> /// Creates a rectangular <see cref="ScanWindow"/>, in mill coordinates, within which a camera will look for the laser. /// </summary> /// <param name="windowTop">The top boundary of the <see cref="ScanWindow"/> in inches. /// Must be greater than <paramref name="windowBottom"/>.</param> /// <param name="windowBottom">The bottom boundary of the <see cref="ScanWindow"/> in inches. /// Must be less than <paramref name="windowTop"/>.</param> /// <param name="windowLeft">The left boundary of the <see cref="ScanWindow"/> in inches. /// Must be less than <paramref name="windowRight"/>.</param> /// <param name="windowRight">The right boundary of the <see cref="ScanWindow"/> in inches. /// Must be greater than <paramref name="windowLeft"/>.</param> /// <returns>The created <see cref="ScanWindow"/>.</returns> /// <seealso cref="ScanHead.SetWindow(ScanWindow)"/> /// <exception cref="ArgumentException"> /// One or more arguments are <see cref="double.NaN"/><br/> /// -or-<br/> /// One or more arguments are <see cref="double.NegativeInfinity"/> or <see cref="double.PositiveInfinity"/><br/> /// -or-<br/> /// <paramref name="windowTop"/> is less than or equal to <paramref name="windowBottom"/><br/> /// -or-<br/> /// <paramref name="windowRight"/> is less than or equal to <paramref name="windowLeft"/> /// </exception> public static ScanWindow CreateScanWindowRectangular(double windowTop, double windowBottom, double windowLeft, double windowRight) { if (double.IsNaN(windowTop) || double.IsNaN(windowBottom) || double.IsNaN(windowLeft) || double.IsNaN(windowRight)) { throw new ArgumentException("One or more arguments are Double.NaN."); } if (double.IsInfinity(windowTop) || double.IsInfinity(windowBottom) || double.IsInfinity(windowLeft) || double.IsInfinity(windowRight)) { throw new ArgumentException( "One or more arguments are Double.NegativeInfinity or Double.PositiveInfinity."); } if (windowTop <= windowBottom) { throw new ArgumentException($"{nameof(windowTop)} must be greater than {nameof(windowBottom)}"); } if (windowRight <= windowLeft) { throw new ArgumentException($"{nameof(windowRight)} must be greater than {nameof(windowLeft)}"); } var scanWindow = new ScanWindow(); scanWindow.WindowConstraints.Add(new WindowConstraint(windowLeft, windowTop, windowRight, windowTop)); scanWindow.WindowConstraints.Add(new WindowConstraint(windowRight, windowBottom, windowLeft, windowBottom)); scanWindow.WindowConstraints.Add(new WindowConstraint(windowRight, windowTop, windowRight, windowBottom)); scanWindow.WindowConstraints.Add(new WindowConstraint(windowLeft, windowBottom, windowLeft, windowTop)); return(scanWindow); }