예제 #1
0
        /// <summary>
        /// Access to a specific reference child
        /// If it dosen't exit, it is created
        /// </summary>
        public G3DCompBase GetRef(string name)
        {
            G3DCompBase reference = this[name] as GReference;

            if (reference == null)
            {
                reference = new GReference(name);
                Add(reference);
            }
            return(reference);
        }
예제 #2
0
        /// <summary>
        /// Transform a point Z to the
        /// </summary>
        /// <param name="Z"></param>
        /// <returns></returns>
        public Millimeters TransformZ(Millimeters Z)
        {
            G3DCompBase reference = Container;

            Z += Loc.Z;
            if (reference == null || Loc.ZMode == G3DPoint.eMode.Absolute)
            {
                return(Z);
            }
            return(reference.TransformZ(Z));
        }
예제 #3
0
        /// <summary>
        /// Convert Pixel point to MM in PointF
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        public PointF ConvertFromPixels(PointF pt)
        {
            G3DCompBase compTransferFuncs = TransferFuncComp;

            if (compTransferFuncs != null && compTransferFuncs.PixToMMX != null && compTransferFuncs.PixToMMX != null)
            {
                float mmX = (float)compTransferFuncs.PixToMMX.Evaluate(pt.X, pt.Y);
                float mmY = (float)compTransferFuncs.PixToMMY.Evaluate(pt.X, pt.Y);
                return(new PointF(mmX, mmY));
            }
            return(PointF.Empty);
        }
예제 #4
0
        /// <summary>
        /// Set the Location according to an image correction from the center of the image
        /// </summary>
        /// <param name="pixelX"></param>
        /// <param name="pixelY"></param>
        /// <param name="theta"></param>
        /// <returns></returns>
        public G3DPoint ConvertFromPixels(double pixelX, double pixelY, Radians theta)
        {
            G3DCompBase compTransferFuncs = TransferFuncComp;

            if (compTransferFuncs != null && compTransferFuncs.PixToMMX != null && compTransferFuncs.PixToMMX != null)
            {
                Loc.X.Val = compTransferFuncs.PixToMMX.Evaluate(pixelX, pixelY);
                Loc.Y.Val = compTransferFuncs.PixToMMY.Evaluate(pixelX, pixelY);
                Loc.Yaw   = -theta;
            }
            return(Loc);
        }
예제 #5
0
        /// <summary>
        /// Convert the specific point to pixel space
        /// </summary>
        /// <param name="absPt"></param>
        /// <returns></returns>
        public PointF AbsPointToPixel(double x, double y)
        {
            PointF      retPt             = PointF.Empty;
            G3DCompBase compTransferFuncs = TransferFuncComp;

            if (compTransferFuncs != null && compTransferFuncs.MMToPixX != null && compTransferFuncs.MMToPixX != null)
            {
                retPt.X = (float)compTransferFuncs.MMToPixX.Evaluate(x, y);
                retPt.Y = (float)compTransferFuncs.MMToPixY.Evaluate(x, y);
                return(retPt);
            }
            return(retPt);
        }
예제 #6
0
        /// <summary>
        /// Make a copy
        /// </summary>
        /// <param name="name"></param>
        /// <param name="bRecursivley"></param>
        /// <returns></returns>
        public override CompBase Clone(string name, bool bRecursivley)
        {
            G3DCompBase newComp = base.Clone(name, bRecursivley) as G3DCompBase;

            newComp.Loc               = new G3DPoint(Loc);
            newComp._speed.Val        = _speed;
            newComp._pulseWidth.Val   = _pulseWidth;
            newComp.ToolDelay.Val     = ToolDelay;
            newComp.DispenseZHtTarget = DispenseZHtTarget;
            newComp.EditorZoom        = EditorZoom;
            newComp.EditorFocusPt     = EditorFocusPt;
            newComp.EditorImageAngle  = EditorImageAngle;
            return(newComp);
        }
예제 #7
0
        /// <summary>
        /// Get the absolute robot coordinates (Used for Line elements: Trigger)
        /// </summary>
        /// <param name="distance">Distance along the Loc vector (angle of Yaw) </param>
        /// <param name="applyToolOffset"> Ad the too offset to adjust for tool moounting position</param>
        /// <returns></returns>
        public G3DPoint GetRobotLoc(Millimeters distance, bool applyToolOffset)
        {
            if (Loc.XYYawMode == G3DPoint.eMode.Absolute)
            {
                double x = distance * Math.Cos(Loc.Yaw);
                double y = distance * Math.Sin(Loc.Yaw);
                if (Loc.ZMode == G3DPoint.eMode.Absolute)
                {
                    return(new G3DPoint(Loc.X + x, Loc.Y + y, Loc.Z));
                }
                else
                {
                    return(new G3DPoint(Loc.X + x, Loc.Y + y, 0));
                }
            }

            G3DPoint pt = TransformXY(distance, 0);

            if (Loc.ZMode == G3DPoint.eMode.Absolute)
            {
                pt.Z.Val = Loc.Z;
            }
            else
            {
                pt.Z.Val = TransformZ(0);
            }

            if (applyToolOffset && ToolComp != null)
            {
                if (_offsetComp == null && _offsetCompCheck == false)
                {
                    _offsetComp      = ToolComp.FilterByTypeSingle <G3DCompBase>();
                    _offsetCompCheck = true;
                }
                if (_offsetComp != null)
                {
                    pt.X += _offsetComp.Loc.X;
                    pt.Y += _offsetComp.Loc.Y;
                    if (Loc.ZMode == G3DPoint.eMode.Relative)
                    {
                        pt.Z += _offsetComp.Loc.Z;
                    }
                }
            }
            return(pt);
        }
예제 #8
0
        /// <summary>
        /// Transform a point (x,y) to the
        /// </summary>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <returns></returns>
        public G3DPoint TransformXY(Millimeters X, Millimeters Y)
        {
            G3DCompBase reference = Container;

            if (Loc.XYYawMode == G3DPoint.eMode.Absolute)
            {
                return(new G3DPoint(Loc.X + X, Loc.Y + Y, 0.0));
            }
            G3DPoint outerPt = outerPt = new G3DPoint(Loc);
            double   dist    = Math.Sqrt(X * X + Y * Y);
            double   theta   = Math.Atan2(Y, X);

            outerPt.X += dist * Math.Cos(theta + Loc.Yaw);
            outerPt.Y += dist * Math.Sin(theta + Loc.Yaw);
            if (reference == null)
            {
                return(outerPt);
            }
            return(reference.TransformXY(outerPt.X, outerPt.Y));
        }