示例#1
0
    public void Set(DXFStructure dxf)
    {
        //先初始化图层
        foreach (TABLE table in dxf.TABLES.TABLEList)
        {
            if (table.LAYERList.Count == 0)
            {
                continue;
            }

            foreach (LAYER item in table.LAYERList)
            {
                GameObject go = Instantiate(Layer) as GameObject;
                go.transform.parent = gameObject.transform;
                var l = go.GetComponent <GoLayer>();
                l.Set(item);

                if (item.C2 != null && !Layers.ContainsKey(item.C2))
                {
                    Layers.Add(item.C2, l);
                }
            }
        }

        //构建一个默认图层,没有图层属性的对象放在此图层
        GameObject goDefaultLayer = Instantiate(Layer) as GameObject;

        GoLayer.DefaultLayer            = goDefaultLayer.GetComponent <GoLayer>();
        GoLayer.DefaultLayer.ZoomAdjust = 0.8f;

        //绘制各图层下的元素
        foreach (var item in Layers)
        {
            item.Value.Load(dxf);
        }

        //初始化相机位置
        //camera.transform.position = new Vector3((MaxX + MinX) / 2, (MaxY + MinY) / 2, -10);

        this.transform.position = new Vector3(this.transform.position.x - (MaxX + MinX) / 2,
                                              this.transform.position.y - (MaxY + MinY) / 2,
                                              0);

        camera.orthographicSize = ((MaxX - MinX) + (MaxY - MinY)) / 20;

        Zoom = (camera.orthographicSize / 250);


        //初始化优化代码
        ResizeObjects.ForEach((l) =>
        {
            l.ToMin();
            if (l.gameObject.activeSelf)
            {
                l.SetSetWidth();
            }
        });
    }
 //绘制块集合
 public void DrawINSERTList(DXFStructure dxf, List <INSERT> INSERTList, float ScaleX = 1, float ScaleY = 1)
 {
     foreach (var item in INSERTList)
     {
         GameObject go = Instantiate(GoInsert) as GameObject;
         go.transform.parent = gameObject.transform;
         var l = go.GetComponent <GoInsert>();
         l.Set(dxf, item);
     }
 }
示例#3
0
 //绘制直线集合
 public void DrawLINEList(DXFStructure dxf, List <LINE> LINEList)
 {
     //绘制直线
     foreach (LINE item in LINEList)
     {
         GameObject go = Instantiate(TLine) as GameObject;
         go.transform.parent = gameObject.transform;
         var l = go.GetComponent <TLine>();
         l.Set(dxf, item);
     }
 }
 //绘制圆集合
 public void DrawCIRCLEList(DXFStructure dxf, List <CIRCLE> CIRCLEList, float ScaleX = 1, float ScaleY = 1)
 {
     // 绘制圆
     foreach (var item in CIRCLEList)
     {
         GameObject go = Instantiate(GoCircle) as GameObject;
         go.transform.parent = gameObject.transform;
         var l = go.GetComponent <GoCircle>();
         l.Set(dxf, item, ScaleX, ScaleY);
     }
 }
 //绘制文本集合
 public void DrawTEXTList(DXFStructure dxf, List <TEXT> TEXTList, float ScaleX = 1, float ScaleY = 1)
 {
     //绘制直线
     foreach (TEXT item in TEXTList)
     {
         GameObject go = Instantiate(GoText) as GameObject;
         go.transform.parent = gameObject.transform;
         var l = go.GetComponent <GoText>();
         l.Set(dxf, item, ScaleX, ScaleY);
     }
 }
 //绘制多段线集合
 public void DrawLWPOLYLINEList(DXFStructure dxf, List <LWPOLYLINE> LWPOLYLINEList, float ScaleX = 1, float ScaleY = 1)
 {
     // 多段线
     foreach (var item in LWPOLYLINEList)
     {
         GameObject go = Instantiate(GoLwpolyLine) as GameObject;
         go.transform.parent = gameObject.transform;
         var l = go.GetComponent <GoLwpolyLine>();
         l.Set(dxf, item, ScaleX, ScaleY);
     }
 }
 //绘制椭圆集合
 public void DrawELLIPSEList(DXFStructure dxf, List <ELLIPSE> ELLIPSEList, float ScaleX = 1, float ScaleY = 1)
 {
     //绘制椭圆
     foreach (var item in ELLIPSEList)
     {
         GameObject go = Instantiate(GoEllipse) as GameObject;
         go.transform.parent = gameObject.transform;
         var l = go.GetComponent <GoEllipse>();
         l.Set(dxf, item, ScaleX, ScaleY);
     }
 }
示例#8
0
    // Update is called once per frame
    //void Update () {
    //    if (GoView.Content.Zoom > HideSize)
    //    {
    //        mr.enabled = false;
    //        return;
    //    }
    //    mr.enabled = true;
    //}

    public void Set(DXFStructure dxf, TEXT item, float ScaleX = 1, float ScaleY = 1)
    {
        tm.color           = GoView.Content.GetLayerMaterial(item.C8).color;
        transform.position = new Vector3((float)item.C10, (float)item.C20, (float)item.C30);
        tm.text            = item.C1;
        tm.characterSize   = (float)item.C40 / 5;

        HideSize = tm.characterSize * tm.text.Length;

        this.gameObject.isStatic = true;
    }
    //绘制圆弧集合
    public void DrawARCList(DXFStructure dxf, List <ARC> ARCList, float ScaleX = 1, float ScaleY = 1)
    {
        //绘制弧线
        int ii = 0;

        foreach (var item in ARCList)
        {
            GameObject go = Instantiate(GoArc) as GameObject;
            go.transform.parent = gameObject.transform;
            var l = go.GetComponent <GoArc>();
            l.Set(dxf, item, ScaleX, ScaleY);

            ii++;
            System.Diagnostics.Debug.WriteLine(ii.ToString());
        }
    }
示例#10
0
    public void Set(DXFStructure dxf)
    {
        //先初始化图层
        foreach (TABLE table in dxf.TABLES.TABLEList)
        {
            if (table.LAYERList.Count == 0)
            {
                continue;
            }

            foreach (LAYER item in table.LAYERList)
            {
                if (item.C2 != null && item.C2 == "HD")
                {
                    GameObject go = Instantiate(LayerGO) as GameObject;
                    go.transform.parent = gameObject.transform;
                    var l = go.GetComponent <TLayerBase>();
                    l.Set(item);
                    Layers.Add(item.C2, l);
                }
            }
        }

        //构建一个默认图层,没有图层属性的对象放在此图层
        //GameObject goDefaultLayer = Instantiate(LayerGO) as GameObject;
        //TLayerBase.DefaultLayer = goDefaultLayer.GetComponent<TLayerBase>();

        //绘制各图层下的元素
        foreach (var item in Layers)
        {
            item.Value.Load(dxf);
        }
        Layers.Clear();
        //初始化优化代码
        ResizeObjects.ForEach((l) =>
        {
            l.ToMin();
            if (l.gameObject.activeSelf)
            {
                l.SetSetWidth();
            }
        });
    }
示例#11
0
    public void Load(DXFStructure dxf)
    {
        //找到当前层的物体
        LINEList  = dxf.ENTITIES.LINEList.Where(x => x.C8 == Layer.C2).ToList();
        TEXTList  = dxf.ENTITIES.TEXTList.Where(x => x.C8 == Layer.C2).ToList();
        POINTList = dxf.ENTITIES.POINTList.Where(x => x.C8 == Layer.C2).ToList();
        //AutoScaleText = dxf.ENTITIES.TEXTList.Where(x=>x.C8 == "BL").ToList();

        //if (AutoScaleText.Count == 0) {
        //    Debug.Log("CAD比例尺未标定!");
        //}

        //绘制层下属物体
        DrawLINEList(LINEList);
        GenNodeList();
        ResetCenterPos();
        Invoke("DrawPointLater", 0.1f);
        Invoke("TelPageLater", 1);
    }
示例#12
0
    // //Update is called once per frame
    //void Update()
    //{
    //    if (GoView.Content.Zoom > LineLenght)
    //    {
    //        lr.enabled = false;
    //        return;
    //    }
    //    lr.enabled = true;
    //    //lr.SetWidth(GoView.Content.Zoom * ZoomAdjust, GoView.Content.Zoom * ZoomAdjust);
    //}


    //设置线段
    public void Set(DXFStructure dxf, LINE item, float ScaleX = 1, float ScaleY = 1)
    {
        var goLayer = GoView.Content.GetLayer(item.C8);

        if (goLayer != null)
        {
            lr.material = goLayer.LayerMaterial;
            ZoomAdjust  = goLayer.ZoomAdjust;
        }

        gg = goLayer;

        lr.SetVertexCount(2);

        var p1 = new Vector3((float)item.C10 * ScaleX, (float)item.C20 * ScaleY, (float)item.C30);
        var p2 = new Vector3((float)item.C11 * ScaleX, (float)item.C21 * ScaleY, (float)item.C31);

        lr.SetPosition(0, p1);
        lr.SetPosition(1, p2);

        LineLenght = Vector2.Distance(p1, p2) * 2;

        this.gameObject.isStatic = true;

        if (GoView.Content.MaxX < p1.x)
        {
            GoView.Content.MaxX = p1.x;
        }
        if (GoView.Content.MinX > p1.x)
        {
            GoView.Content.MinX = p1.x;
        }

        if (GoView.Content.MaxY < p1.y)
        {
            GoView.Content.MaxY = p1.y;
        }
        if (GoView.Content.MinY > p1.y)
        {
            GoView.Content.MinY = p1.y;
        }
    }
示例#13
0
    public void Load(DXFStructure dxf)
    {
        //找到当前层的物体
        LINEList = dxf.ENTITIES.LINEList.Where(x => x.C8 == Layer.C2).ToList();
        //LWPOLYLINEList = dxf.ENTITIES.LWPOLYLINEList.Where(x => x.C8 == Layer.C2).ToList();
        //TEXTList = dxf.ENTITIES.TEXTList.Where(x => x.C8 == Layer.C2).ToList();
        //CIRCLEList = dxf.ENTITIES.CIRCLEList.Where(x => x.C8 == Layer.C2).ToList();
        //ARCList = dxf.ENTITIES.ARCList.Where(x => x.C8 == Layer.C2).ToList();
        //INSERTList = dxf.ENTITIES.INSERTList.Where(x => x.C8 == Layer.C2).ToList();
        //ELLIPSEList = dxf.ENTITIES.ELLIPSEList.Where(x => x.C8 == Layer.C2).ToList();


        //绘制层下属物体
        DrawLINEList(dxf, LINEList);
        //DrawLWPOLYLINEList(dxf, LWPOLYLINEList);
        //DrawTEXTList(dxf, TEXTList);
        //DrawCIRCLEList(dxf, CIRCLEList);
        //DrawARCList(dxf, ARCList);
        //DrawINSERTList(dxf, INSERTList);
        //DrawELLIPSEList(dxf, ELLIPSEList);
    }
    // Update is called once per frame

    public void Set(DXFStructure dxf, LWPOLYLINE item, float ScaleX = 1, float ScaleY = 1)
    {
        var goLayer = GoView.Content.GetLayer(item.C8);

        for (int i = 0; i < item.P2D.Count - 1; i++)
        {
            // lr.SetPosition(i, new Vector3((float)item.P2D[i].X * ScaleX, (float)item.P2D[i].Y * ScaleY, 0));

            GameObject go = Instantiate(goLine) as GameObject;
            go.transform.parent = gameObject.transform;
            var l = go.GetComponent <GoLine>();
            l.Set(dxf, item.P2D[i], item.P2D[i + 1], goLayer, ScaleX, ScaleY);
        }

        if (item.C70 == 1 && item.P2D.Count > 2)
        {
            GameObject go = Instantiate(goLine) as GameObject;
            go.transform.parent = gameObject.transform;
            var l = go.GetComponent <GoLine>();
            l.Set(dxf, item.P2D[item.P2D.Count - 1], item.P2D[0], goLayer, ScaleX, ScaleY);
        }
    }
示例#15
0
    public void Set(DXFStructure dxf, LINE item)
    {
        var goLayer = TView.Content.GetLayer(item.C8);

        if (goLayer != null)
        {
            GenerateLine();
        }

        var p1 = new Vector3((float)item.C10, (float)item.C30, (float)item.C20);
        var p2 = new Vector3((float)item.C11, (float)item.C31, (float)item.C21);

        MeshGenerater.DataContainer.GetInstance().AddCommonNode(p1);
        MeshGenerater.DataContainer.GetInstance().AddCommonNode(p2);

        LineLenght = Vector3.Distance(p1, p2) / 1.905f;

        go.transform.localScale    = new Vector3(10, 10, LineLenght);
        go.transform.localPosition = (p1 + p2) / 2;
        go.transform.LookAt(p2);

        gameObject.isStatic = true;
    }
示例#16
0
    public int OptimizingLevel = 10;  //优化等级,数字越大优化级别越高,越容易失真

    public void Set(DXFStructure dxf, CIRCLE item, float ScaleX = 1, float ScaleY = 1)
    {
        var goLayer = GoView.Content.GetLayer(item.C8);

        if (goLayer != null)
        {
            lr.material = goLayer.LayerMaterial;
            ZoomAdjust  = goLayer.ZoomAdjust;
        }

        float R = (float)item.C40;

        Diameter = R * 2;
        //计算一个圆需要多少线条
        int resolution = (int)item.C40 / OptimizingLevel;

        if (resolution > MaxResolution)
        {
            resolution = MaxResolution;
        }
        if (resolution < MinResolution)
        {
            resolution = MinResolution;
        }

        lr.SetVertexCount(resolution + 1);

        for (int i = 0; i < resolution; ++i)
        {
            lr.SetPosition(i, new Vector3((R * Mathf.Cos(2 * Mathf.PI / resolution * i) + (float)item.C10) * ScaleX,
                                          (R * Mathf.Sin(2 * Mathf.PI / resolution * i) + (float)item.C20) * ScaleY, 0));
        }
        lr.SetPosition(resolution, new Vector3((R * Mathf.Cos(2 * Mathf.PI / resolution * 0) + (float)item.C10) * ScaleX,
                                               (R * Mathf.Sin(2 * Mathf.PI / resolution * 0) + (float)item.C20) * ScaleY, 0));

        this.gameObject.isStatic = true;
    }