コード例 #1
0
    /// <summary>
    /// 设置编辑的设备信息
    /// </summary>
    /// <param name="dev"></param>
    public void SetDeviceInfo(DevNode dev)
    {
        SetCameraWindow(dev);
        window.SetActive(true);
        CurrentDev          = dev;
        NameField.text      = dev.Info.Name;
        IDField.text        = dev.Info.KKSCode;
        AbtmentIDField.text = dev.Info.Abutment_DevID;
        DevPos devPos = dev.Info.Pos;

        if (devPos != null)
        {
            Vector3 cadPos  = new Vector3(devPos.PosX, devPos.PosY, devPos.PosZ);
            bool    isLocal = CurrentDev.IsLocal();
            Vector3 pos     = LocationManager.CadToUnityPos(cadPos, isLocal);
            XPosField.text = Math.Round(pos.x, 2).ToString(CultureInfo.InvariantCulture);
            YPosField.text = Math.Round(pos.y, 2).ToString(CultureInfo.InvariantCulture);
            ZPosField.text = Math.Round(pos.z, 2).ToString(CultureInfo.InvariantCulture);

            AngleField.text = Math.Round(devPos.RotationY, 2).ToString(CultureInfo.InvariantCulture);

            CadPosA.text = Math.Round(devPos.PosZ, 2).ToString(CultureInfo.InvariantCulture);
            CadPosB.text = Math.Round(devPos.PosX, 2).ToString(CultureInfo.InvariantCulture);
        }
        else
        {
            Debug.LogError("DevPos is null:" + dev.Info.Name);
            //ClearValue();
        }
        SetAnglePosInputState(dev);
    }
コード例 #2
0
    /// <summary>
    /// 是否在非生产区域
    /// </summary>
    /// <param name="pos"></param>
    /// <returns></returns>
    public bool IsInNonProductionArea(Vector3 cadPos)
    {
        if (nonProdctionAreas == null)
        {
            BoxCollider[] cols = transform.GetComponentsInChildren <BoxCollider>(false);
            if (cols == null || cols.Length == 0)
            {
                return(false);
            }
            else
            {
                nonProdctionAreas = new List <BoxCollider>();
                nonProdctionAreas.AddRange(cols);
            }
        }
        if (nonProdctionAreas == null || nonProdctionAreas.Count == 0)
        {
            return(false);
        }
        Vector3 unityPos = LocationManager.CadToUnityPos(cadPos, false);

        unityPos.y = 1;//高度默认1,主要是计算X和Z
        foreach (var box in nonProdctionAreas)
        {
            if (box.bounds.Contains(unityPos))
            {
                return(true);
            }
        }
        return(false);
    }
コード例 #3
0
    /// <summary>
    /// 设置编辑的设备信息
    /// </summary>
    /// <param name="dev"></param>
    public void SetDeviceInfo(DevNode dev)
    {
        window.SetActive(true);
        CurrentDev     = dev;
        NameInput.text = dev.Info.Name;
        IDField.text   = dev.Info.KKSCode;
        DevPos devPos = dev.Info.Pos;

        if (devPos != null)
        {
            Vector3 cadPos     = new Vector3(devPos.PosX, devPos.PosY, devPos.PosZ);
            bool    isLocation = !(CurrentDev.ParentDepNode == FactoryDepManager.Instance);
            Vector3 pos        = LocationManager.CadToUnityPos(cadPos, isLocation);
            XPosInput.text = Math.Round(pos.x, 2).ToString();
            YPosInput.text = Math.Round(pos.y, 2).ToString();
            ZPosInput.text = Math.Round(pos.z, 2).ToString();

            AngleInput.text = Math.Round(devPos.RotationY, 2).ToString();

            ScaleXInput.text = Math.Round(devPos.ScaleX, 2).ToString();
            ScaleYInput.text = Math.Round(devPos.ScaleY, 2).ToString();
            ScaleZInput.text = Math.Round(devPos.ScaleZ, 2).ToString();
        }
        else
        {
            Debug.LogError("DevPos is null:" + dev.Info.Name);
            //ClearValue();
        }
    }
コード例 #4
0
    //private IEnumerator CreateBlocks(List<PhysicalTopology> blockList,GameObject devContainer)
    //{
    //    foreach(var block in blockList)
    //    {
    //        Bound initBound = block.InitBound;
    //        if (initBound != null && initBound.Points != null)
    //        {
    //            Point[] points = initBound.Points;
    //            if (points.Length == 4)
    //            {
    //                Vector3 pos = Vector3.zero;
    //                float width = 0;
    //                float length = 0;
    //                GetCADBlockSize(points, ref pos, ref width, ref length);
    //                Debug.Log(string.Format("Pos:{0} width:{1} length:{2}", pos, width, length));

    //                GameObject blockObj = GameObject.CreatePrimitive(PrimitiveType.Cube);
    //                blockObj.transform.parent = devContainer.transform;
    //                blockObj.transform.localScale = new Vector3(width,blockHeight,length);
    //                blockObj.transform.localPosition = pos;
    //                blockObj.transform.localEulerAngles = Vector3.zero;
    //            }
    //        }
    //        yield return null;
    //    }
    //    Debug.LogError("Block Create Complete,Block Count:"+blockList.Count);
    //}
    private void GetCADBlockSize(Point1[] pointGroup, ref Vector3 pos, ref float width, ref float length)
    {
        Vector3 locationScale = LocationManager.Instance.LocationOffsetScale;

        float maxX = float.MinValue;
        float maxY = float.MinValue;
        float minX = float.MaxValue;
        float minY = float.MaxValue;

        foreach (var point in pointGroup)
        {
            if (point.X < minX)
            {
                minX = point.X;
            }
            else if (point.X > maxX)
            {
                maxX = point.X;
            }
            if (point.Y < minY)
            {
                minY = point.Y;
            }
            else if (point.Y > maxY)
            {
                maxY = point.Y;
            }
        }
        width   = (maxX - minX);
        length  = (maxY - minY);
        pos     = new Vector3(minX + width / 2, 0, minY + length / 2);
        width  /= locationScale.x;
        length /= locationScale.z;
        pos     = LocationManager.CadToUnityPos(pos, true);
    }
コード例 #5
0
    /// <summary>
    /// 检测输入框的值
    /// </summary>
    private void CheckInputValue()
    {
        if (TypeCodeHelper.IsStaticDev(CurrentDev.Info.TypeCode.ToString()))
        {
            return;
        }
        DevPos  devPos    = CurrentDev.Info.Pos;
        Vector3 cadPos    = new Vector3(devPos.PosX, devPos.PosY, devPos.PosZ);
        bool    isRoomDev = CurrentDev.IsLocal();
        Vector3 pos       = LocationManager.CadToUnityPos(cadPos, isRoomDev);

        if (string.IsNullOrEmpty(NameField.text))
        {
            NameField.text = CurrentDev.Info.Name;
        }
        CheckEmptyField(XPosField, pos.x);
        CheckEmptyField(YPosField, pos.y);
        CheckEmptyField(ZPosField, pos.z);
        CheckEmptyField(AngleField, devPos.RotationY);
    }
コード例 #6
0
    /// <summary>
    /// 检测输入框的值
    /// </summary>
    private void CheckInputValue()
    {
        if (TypeCodeHelper.IsStaticDev(CurrentDev.Info.TypeCode.ToString()))
        {
            return;
        }
        DevPos  devPos     = CurrentDev.Info.Pos;
        Vector3 cadPos     = new Vector3(devPos.PosX, devPos.PosY, devPos.PosZ);
        bool    isLocation = !(CurrentDev as DepDevController);
        Vector3 pos        = LocationManager.CadToUnityPos(cadPos, isLocation);

        if (string.IsNullOrEmpty(NameInput.text))
        {
            NameInput.text = CurrentDev.Info.Name;
        }
        CheckEmptyField(XPosInput, pos.x);
        CheckEmptyField(YPosInput, pos.y);
        CheckEmptyField(ZPosInput, pos.z);
        CheckEmptyField(AngleInput, devPos.RotationY);
        CheckEmptyField(ScaleXInput, 1);
        CheckEmptyField(ScaleYInput, 1);
        CheckEmptyField(ScaleZInput, 1);
    }