/// <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);
    }
    /// <summary>
    /// 保存信息
    /// </summary>
    private void SaveInfo()
    {
        Debug.Log("SaveInfo:" + CurrentDev.Info.Name);
        CheckInputValue();
        DeviceEditUIManager manager = DeviceEditUIManager.Instacne;

        if (CurrentDev != null)
        {
            CurrentDev.Info.Name           = NameField.text;
            CurrentDev.Info.KKSCode        = IDField.text;
            CurrentDev.Info.Abutment_DevID = AbtmentIDField.text;
            string typeCode = CurrentDev.Info.TypeCode.ToString();
            DevPos posInfo  = null;
            if (!TypeCodeHelper.IsStaticDev(typeCode))
            {
                ChangeDevPosAngle();
                bool    isLocal = CurrentDev.IsLocal();
                Vector3 cadPos  = LocationManager.UnityToCadPos(TryParsePos(), isLocal);
                posInfo = CurrentDev.Info.Pos;
                if (posInfo != null)
                {
                    posInfo.PosX      = cadPos.x;
                    posInfo.PosY      = cadPos.y;
                    posInfo.PosZ      = cadPos.z;
                    posInfo.RotationY = AngleField.text.ToFloat();
                }
                manager.ChangeDevFollowInfo(CurrentDev);
                manager.RefleshGizmoPosition();
            }
            manager.ChangeDevFollowInfo(CurrentDev);
            CommunicationObject service = CommunicationObject.Instance;
            if (service)
            {
                service.ModifyDevInfo(CurrentDev.Info);
                if (!TypeCodeHelper.IsStaticDev(typeCode))
                {
                    service.ModifyDevPos(posInfo);
                }
            }
        }
    }
Example #3
0
    /// <summary>
    /// unity位置转换cad位置
    /// </summary>
    /// <param name="dev"></param>
    /// <param name="devNode"></param>
    /// <returns></returns>
    public Vector3 UnityPosToCad(Transform dev, DevNode devNode)
    {
        Vector3 pos;

        if (!devNode.IsLocal())//不在楼层内
        {
            pos = LocationManager.GetCadVector(dev.position);
        }
        else if (devNode != null)
        {
            pos = UnityLocalPosToCad(dev.localPosition);
        }
        else
        {
            Debug.Log("Controller not find..");
            pos = Vector3.zero;
        }
        return(pos);
    }