Example #1
0
        ///<summary>移动</summary>
        void scene_EditObjectMove(object sender, Earth.PickEventArgs e)
        {
            btnSave.IsEnabled = isModify = true;

            if (editobj.modifyStatus == EModifyStatus.未修改)
            {
                editobj.modifyStatus = EModifyStatus.修改;
                editobj.color        = Colors.Red;
            }

            if (editobj is pPowerLine && e.pickedObject is EDDot)  //线路修改,从eddot传递到线路
            {
                assobj = e.pickedObject as EDDot;
                pPowerLine lin = editobj as pPowerLine;
                lin.VecPoints[assobj.order] = assobj.VecLocation;
                lin.sendChangedLocation();
            }
            else if (editobj is pArea && e.pickedObject is EDDot)  //区域修改, 从eddot传递到区域
            {
                assobj = e.pickedObject as EDDot;
                pArea lin = editobj as pArea;
                lin.VecPoints[assobj.order] = assobj.VecLocation;
                lin.sendChangedLocation();
            }
        }
Example #2
0
        private void lstObject_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            //设置当前
            pPowerLine selobj = lstObject.SelectedItem as pPowerLine;


            propObj.SelectedObject = selobj.busiAccount;
            root.earth.camera.aniLook(selobj.VecLocation);
        }
Example #3
0
        private void map_MouseDown(object sender, MouseButtonEventArgs e)
        {
            string id = null;
            //抓取线路
            PowerBasicObject pickobj     = earth.objManager.pick(e.GetPosition(grdMain));
            VECTOR3D?        tmpLocation = earth.earthManager.transformScreenToD3D(e.GetPosition(grdMain));

            if (pickobj != null && pickobj.busiData.busiSort == "线路")
            {
                id = pickobj.id;
            }
            else
            {
                return;
            }

            pPowerLine pline = pickobj as pPowerLine;

            if (isAdding && id != null)
            {
                if (viewmodel.curSection != null)
                {
                    if (viewmodel.curSection.lines.Count(p => p.id == id) == 0)
                    {
                        line nline = new line()
                        {
                            id = id, section = viewmodel.curSection
                        };

                        //zhh注:此下应修改为从数据库中读取相应数据

                        //if (tmpLocation!=null)
                        //    nline.d3dLocation =(VECTOR3D)tmpLocation;
                        //else
                        nline.d3dLocation = pline.VecLocation;
                        nline.name        = pline.name;
                        nline.maxValue    = pline.busiData.busiRatingValue;
                        nline.curValue    = pline.busiData.busiCurValue;

                        //---------


                        viewmodel.curSection.lines.Add(nline);
                        nline.InitVisualControl();

                        if (viewmodel.curSection.isShow)
                        {
                            viewmodel.grid.Children.Add(nline.vLinkLine);
                            viewmodel.grid.Children.Add(nline.vInfo);
                        }
                        viewmodel.curSection.refreshCollection();
                        viewmodel.curSection.refreshLocation();
                        viewmodel.curSection.refreshData();
                    }
                }
            }
        }
Example #4
0
        ///<summary>选中对象</summary>
        void scene_EditObjectSelected(object sender, Earth.PickEventArgs e)
        {
            if (editobj == null)
            {
                editobj               = e.pickedObject;
                isNewObject           = false;
                pgAcnt.SelectedObject = editobj.busiAccount;
                btnCreate.IsEnabled   = false;
                btnDelete.IsEnabled   = true;
                btnSave.IsEnabled     = isModify = false;
                btnExit.IsEnabled     = true;

                if (editobj is pPowerLine) //选中的线段
                {
                    pPowerLine lin = editobj as pPowerLine;
                    int        idx = 0;
                    foreach (Point pnt in lin.points)
                    {
                        EDDot dot = new EDDot(elayer)
                        {
                            id       = MyClassLibrary.helper.getGUID(),
                            location = pnt.ToString(),
                        };
                        dot.order  = idx;
                        dot.scaleX = dot.scaleY = dot.scaleZ = distnet.UnitMeasure * 5;
                        elayer.AddObject(dot);
                        idx++;
                    }
                    distnet.scene.UpdateModel();
                }
                else if (editobj is pArea)  //选中的区域
                {
                    pArea lin = editobj as pArea;
                    int   idx = 0;
                    foreach (Point pnt in lin.points)  //zh注,应改写为原始坐标点集
                    {
                        EDDot dot = new EDDot(elayer)
                        {
                            id       = MyClassLibrary.helper.getGUID(),
                            location = pnt.ToString(),
                        };
                        dot.order  = idx;
                        dot.scaleX = dot.scaleY = dot.scaleZ = distnet.UnitMeasure * 5;
                        elayer.AddObject(dot);
                        idx++;
                    }
                    distnet.scene.UpdateModel();
                }

                oldID = editobj.id;
            }
            else if (e.pickedObject is EDDot)  //选中的控制点, 服务于线段和区域
            {
                assobj = e.pickedObject as EDDot;
                btnDelDot.Visibility = btnAddDot.Visibility = System.Windows.Visibility.Visible;
            }
        }
Example #5
0
        ///<summary>删除线段或多边形控制点</summary>
        private void btnDelDot_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            EDDot dot;

            if (editobj is pPowerLine)
            {
                pPowerLine lin = editobj as pPowerLine;
                int        idx = assobj.order;

                lin.VecPoints.RemoveAt(idx);
                lin.sendChangedLocation();
                elayer.pModels.Remove(assobj.id);

                foreach (PowerBasicObject item in elayer.pModels.Values)  //所有后点序号-1
                {
                    if (item is EDDot)
                    {
                        dot = item as EDDot;
                        if (dot.order > idx)
                        {
                            dot.order = dot.order - 1;
                        }
                    }
                }
            }
            else if (editobj is pArea)
            {
                pArea lin = editobj as pArea;
                int   idx = assobj.order;

                lin.VecPoints.RemoveAt(idx);
                lin.sendChangedLocation();
                elayer.pModels.Remove(assobj.id);

                foreach (PowerBasicObject item in elayer.pModels.Values)  //所有后点序号-1
                {
                    if (item is EDDot)
                    {
                        dot = item as EDDot;
                        if (dot.order > idx)
                        {
                            dot.order = dot.order - 1;
                        }
                    }
                }
            }

            distnet.scene.UpdateModel();
        }
Example #6
0
        void loadModel()
        {
            //读取数据
            curprjkey    = 13;
            dtallproject = DataLayer.DataProvider.getDataTableFromSQL("select * from map_project");
            dtproject    = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select * from map_project where id={0}", curprjkey));
            curprj       = dtproject.Rows[0];
            string sqlwhere  = PrjHelper.genProjectsExpress(curprjkey, dtallproject);
            string sqlwhere2 = PrjHelper.genProjectsExpress(curprjkey, dtallproject, "t1.");

            dtobject = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select t1.*,t2.layer from map_object t1 join map_svg_layer t2 on t1.layerid=t2.id where points is not null and {0}", sqlwhere2));
            dtlayer  = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select * from map_svg_layer where {0}", sqlwhere));
            dttext   = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select t1.*,t2.layer from map_svg_text t1 join map_svg_layer t2 on t1.layerid=t2.id where points is not null and {0}", sqlwhere2));
            dtsymbol = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select t2.svgsymbolid,t2.name,t2.viewbox,t2.preserveAspectRatio,t1.shapetype,t1.data,t1.fill,t1.stroke,t1.width from map_svg_symbolitem t1 join map_svg_symbol t2 on t1.symbolid=t2.id where t2.svgsymbolid in (select distinct replace(symbolid,'#','') from map_object where points is not null and ({0})) and ({0})", sqlwhere)); //仅使用了的图元

            dtstyle = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select * from map_svg_style where {0}", sqlwhere));
            int KGID = 11;

            dtshareobject = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select * from map_share_object where prjid={0} or layername='区县图层'", KGID));

            //生成图元字典,图元字典内容会被传送到d3d生成公用材质,下面的厂站,将使用图元字典中的键值来决定在d3d中的材质
            genSymbolBrush();
            //另外直接添加材质, SubstationEntityDisH2为键值
            //uc.objManager.AddSymbol("","SubstationEntityDisH2", "SubstationEntityDisH2.dds");


            //生成几何体资源字典,几何体资源字典内容会被传送到d3d生成公用几何体数据,下面的数据呈现用的柱体,将使用几何体字典中的键值来决定在d3d中的形态
            genGeomeries();


            //添加对象层
            foreach (DataRow item in dtlayer.Rows)
            {
                uc.objManager.AddLayer(item["layer"].ToString(), item["id"].ToString(), item["layer"].ToString()); //示例中以层的名字为键值
            }
            int idx = 0;
            //对象
            bool             isfind;
            PowerBasicObject obj;
            pLayer           containerLayer;



            foreach (DataRow item in dtobject.AsEnumerable().OrderBy(p => p.Field <int>("prjid")))
            {
                obj = null;
                if (item["shapetype"].ToString() == "dot")
                {
                    isfind = uc.objManager.zLayers.TryGetValue(item["layer"].ToString(), out containerLayer);  //查找是否有对象所属层
                    if (isfind)
                    {
                        isfind = containerLayer.pModels.TryGetValue(item["id"].ToString(), out obj);
                        if (!isfind)
                        {
                            obj = new pSymbolObject(containerLayer)
                            {
                                id       = item["id"].ToString(),
                                name     = item["objname"].ToString(),
                                location = item["points"].ToString(),
                                symbolid = item["symbolid"].ToString().Replace("#", ""),  //材质Key
                                isH      = true
                            };
                            if ((obj as pSymbolObject).symbolid == "SwitchStationOpen")
                            {
                                if (obj.busiData == null)
                                {
                                    obj.busiData = new busiBase(obj);
                                }
                                obj.busiData.busiSort        = "开关站";
                                (obj as pSymbolObject).color = Colors.Aqua;
                                obj.visualMaxDistance        = 10;
                            }
                            else if ((obj as pSymbolObject).symbolid == "SubstationEntityDisH")
                            {
                                if (obj.busiData == null)
                                {
                                    obj.busiData = new busiBase(obj);
                                }
                                obj.busiData.busiSort        = "变电站";
                                (obj as pSymbolObject).color = Colors.Lime;
                            }
                            else if ((obj as pSymbolObject).symbolid == "Pole")
                            {
                                if (obj.busiData == null)
                                {
                                    obj.busiData = new busiBase(obj);
                                }
                                obj.busiData.busiSort        = "杆塔";
                                (obj as pSymbolObject).color = Color.FromRgb(0xCC, 0xFF, 0xFF);
                                obj.visualMaxDistance        = 5;
                            }

                            //(obj as pSymbolObject).aniTwinkle.isDoAni = true;


                            Regex regex = new Regex("translate\\(.*\\) ?rotate\\(.*\\) ?scale\\((\\d*.?\\d*), ?(\\d*.?\\d*)\\)", RegexOptions.Multiline);
                            Match m     = regex.Match(item["data"].ToString());
                            if (m.Success)
                            {
                                (obj as pSymbolObject).scaleX = (float)(uc.objManager.zSymbols[(obj as pSymbolObject).symbolid].sizeX * Math.Pow(double.Parse(m.Groups[1].Value), 0.7) / 400);
                                (obj as pSymbolObject).scaleY = (float)(uc.objManager.zSymbols[(obj as pSymbolObject).symbolid].sizeY * Math.Pow(double.Parse(m.Groups[1].Value), 0.7) / 400);
                            }
                            else
                            {
                                (obj as pSymbolObject).scaleX = (obj as pSymbolObject).scaleY = 0.025f;
                            }


                            containerLayer.AddObject(item["id"].ToString(), obj);//也可直接加如:containerLayer.pModels.Add(item["id"].ToString(), obj);
                        }
                    }
                    if (idx == 0)
                    {
                        obj = new pModel3D(containerLayer)  //测试实物模型用,暂无效
                        {
                            id          = item["id"].ToString() + "3d",
                            name        = item["objname"].ToString(),
                            location    = item["points"].ToString(),
                            Model3DType = EPowerModel3DType.风电
                        };
                        containerLayer.AddObject(item["id"].ToString() + "3d", obj);
                        idx++;
                    }
                }
                else if (item["shapetype"].ToString() == "path")
                {
                    isfind = uc.objManager.zLayers.TryGetValue(item["layer"].ToString(), out containerLayer);
                    if (isfind)
                    {
                        isfind = containerLayer.pModels.TryGetValue(item["id"].ToString(), out obj);
                        if (!isfind)
                        {
                            obj = new pPowerLine(containerLayer)
                            {
                                id         = item["id"].ToString(),
                                name       = item["objname"].ToString(),
                                strPoints  = item["points"].ToString(),
                                color      = Color.FromRgb(0xFF, 0xCC, 0x00),
                                arrowColor = Colors.Blue,
                                isFlow     = true,
                                thickness  = 0.002f
                            };
                            //(obj as pPowerLine).aniDraw.aniType=EAniType.绘制; //注意:只有aniDraw属性可以是擦除或绘制两者之一,其它的动画属性大多没有可选性,请不要更改它们的动画类型
                            //(obj as pPowerLine).aniDraw.isDoAni = true;
                            //(obj as pPowerLine).aniTwinkle.isDoAni = true;

                            //zh注:对不合理的过近的相邻点进行处理,这部分应放入位置数据入库前
                            PointCollection pc    = PointCollection.Parse(item["points"].ToString());
                            PointCollection newpc = new PointCollection();
                            newpc.Add(pc[0]);
                            for (int i = 1; i < pc.Count; i++)
                            {
                                if ((pc[i] - pc[i - 1]).Length > 0.00001)
                                {
                                    if (i < pc.Count - 1)
                                    {
                                        Vector v1 = pc[i] - pc[i - 1]; v1.Normalize();
                                        Vector v2 = pc[i + 1] - pc[i]; v2.Normalize();
                                        if (v1 != v2)
                                        {
                                            newpc.Add(pc[i]);
                                        }
                                    }
                                    else
                                    {
                                        newpc.Add(pc[i]);
                                    }
                                }
                            }
                            (obj as pPowerLine).strPoints = newpc.ToString();


                            if (newpc.Count > 1)
                            {
                                containerLayer.pModels.Add(item["id"].ToString(), obj);
                            }
                        }
                    }


                    idx++;
                }
            }
        }
Example #7
0
        ///<summary>选中对象</summary>
        void scene_EditObjectSelected(object sender, Earth.PickEventArgs e)
        {
            if (isTopoBrowser)  //拓扑浏览模式
            {
                handleTopoBrowsePickedObject(e.pickedObject);
            }
            else  //编辑模式
            {
                #region 编辑模式

                if (e.pickedObject == editobj)
                {
                    return;
                }
                elayer.pModels.Clear();

                if (e.pickedObject is EDDot)  //选中的控制点, 服务于线段和区域
                {
                    assobj = e.pickedObject as EDDot;
                    btnDelDot.Visibility = btnAddDot.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    editobj               = e.pickedObject;
                    isNewObject           = false;
                    pgAcnt.SelectedObject = editobj.busiAccount;
                    //btnCreate.IsEnabled = false;
                    btnDelete.IsEnabled = true;
                    //btnSave.IsEnabled = isModify = false;
                    //btnExit.IsEnabled = true;

                    if (editobj is pPowerLine) //选中的线段
                    {
                        pPowerLine lin = editobj as pPowerLine;
                        int        idx = 0;
                        foreach (Point pnt in lin.points)
                        {
                            EDDot dot = new EDDot(elayer)
                            {
                                id       = MyClassLibrary.helper.getGUID(),
                                location = pnt.ToString(),
                            };
                            dot.order       = idx;
                            dot.scaleX      = dot.scaleY = dot.scaleZ = distnet.UnitMeasure * 5;
                            dot.symbolid    = "小圆圈";
                            dot.isUseXModel = false;
                            elayer.AddObject(dot);
                            idx++;
                        }
                    }
                    else if (editobj is pArea)  //选中的区域
                    {
                        pArea lin = editobj as pArea;
                        int   idx = 0;
                        foreach (Point pnt in lin.points)  //zh注,应改写为原始坐标点集
                        {
                            EDDot dot = new EDDot(elayer)
                            {
                                id       = MyClassLibrary.helper.getGUID(),
                                location = pnt.ToString(),
                            };
                            dot.order  = idx;
                            dot.scaleX = dot.scaleY = dot.scaleZ = distnet.UnitMeasure * 5;
                            elayer.AddObject(dot);
                            idx++;
                        }
                    }

                    distnet.scene.UpdateModel();
                    oldID = editobj.id;
                }
                #endregion
            }

            //if (editobj == null)
            //{
            //    editobj = e.pickedObject;
            //    isNewObject = false;
            //    pgAcnt.SelectedObject = editobj.busiAccount;
            //    btnCreate.IsEnabled = false;
            //    btnDelete.IsEnabled = true;
            //    btnSave.IsEnabled = isModify = false;
            //    btnExit.IsEnabled = true;

            //    if (editobj is pPowerLine) //选中的线段
            //    {
            //        pPowerLine lin = editobj as pPowerLine;
            //        int idx = 0;
            //        foreach (Point pnt in lin.points)
            //        {
            //            EDDot dot = new EDDot(elayer)
            //            {
            //                id=MyClassLibrary.helper.getGUID(),
            //                location=pnt.ToString(),
            //            };
            //            dot.order = idx;
            //            dot.scaleX = dot.scaleY = dot.scaleZ = distnet.UnitMeasure*5;
            //            elayer.AddObject(dot);
            //            idx++;
            //        }
            //        distnet.scene.UpdateModel();
            //    }
            //    else if (editobj is pArea)  //选中的区域
            //    {
            //        pArea lin = editobj as pArea;
            //        int idx = 0;
            //        foreach (Point pnt in lin.points)  //zh注,应改写为原始坐标点集
            //        {
            //            EDDot dot = new EDDot(elayer)
            //            {
            //                id = MyClassLibrary.helper.getGUID(),
            //                location = pnt.ToString(),
            //            };
            //            dot.order = idx;
            //            dot.scaleX = dot.scaleY = dot.scaleZ = distnet.UnitMeasure * 5;
            //            elayer.AddObject(dot);
            //            idx++;
            //        }
            //        distnet.scene.UpdateModel();
            //    }

            //    oldID = editobj.id;
            //}
            //else if (e.pickedObject is EDDot)  //选中的控制点, 服务于线段和区域
            //{
            //    assobj = e.pickedObject as EDDot;
            //    btnDelDot.Visibility = btnAddDot.Visibility = System.Windows.Visibility.Visible;
            //}
        }
Example #8
0
        ///<summary>增加线段或多边形控制点</summary>
        private void btnAddDot_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            EDDot dot;

            if (editobj is pPowerLine)
            {
                pPowerLine lin    = editobj as pPowerLine;
                int        idx    = assobj.order;
                int        idx2   = lin.VecPoints.Count() - 1 == idx ? idx - 1 : idx + 1;
                int        idxmin = Math.Min(idx, idx2);                 //这一点及以前的序号不变
                foreach (PowerBasicObject item in elayer.pModels.Values) //所有后点序号+1
                {
                    if (item is EDDot)
                    {
                        dot = item as EDDot;
                        if (dot.order > idxmin)
                        {
                            dot.order = dot.order + 1;
                        }
                    }
                }

                VECTOR3D np = new VECTOR3D((lin.VecPoints[idx].x + lin.VecPoints[idx2].x) / 2, (lin.VecPoints[idx].y + lin.VecPoints[idx2].y) / 2, (lin.VecPoints[idx].z + lin.VecPoints[idx2].z) / 2);

                lin.VecPoints.Insert(idxmin + 1, np);
                lin.sendChangedLocation();

                System.Windows.Media.Media3D.Point3D p3d = new System.Windows.Media.Media3D.Point3D(np.x, np.y, np.z);
                System.Windows.Media.Media3D.Point3D jwh = Helpler.PointToJWH(p3d, distnet.scene.earthManager.earthpara);
                System.Windows.Point pnt = new System.Windows.Point(jwh.Y, jwh.X);
                if (distnet.scene.coordinateManager.Enable)
                {
                    pnt = distnet.scene.coordinateManager.transToOuter(pnt);                                          //若启用了坐标转换,转换为外部坐标
                }
                dot = new EDDot(elayer)
                {
                    id       = MyClassLibrary.helper.getGUID(),
                    location = pnt.ToString(),
                };
                dot.order  = idxmin + 1;
                dot.scaleX = dot.scaleY = dot.scaleZ = distnet.UnitMeasure * 5;
                elayer.AddObject(dot);
            }
            else if (editobj is pArea)
            {
                pArea lin    = editobj as pArea;
                int   idx    = assobj.order;
                int   idx2   = lin.VecPoints.Count() - 1 == idx ? idx - 1 : idx + 1;
                int   idxmin = Math.Min(idx, idx2);                      //这一点及以前的序号不变
                foreach (PowerBasicObject item in elayer.pModels.Values) //所有后点序号+1
                {
                    if (item is EDDot)
                    {
                        dot = item as EDDot;
                        if (dot.order > idxmin)
                        {
                            dot.order = dot.order + 1;
                        }
                    }
                }

                VECTOR3D np = new VECTOR3D((lin.VecPoints[idx].x + lin.VecPoints[idx2].x) / 2, (lin.VecPoints[idx].y + lin.VecPoints[idx2].y) / 2, (lin.VecPoints[idx].z + lin.VecPoints[idx2].z) / 2);

                lin.VecPoints.Insert(idxmin + 1, np);
                lin.sendChangedLocation();

                System.Windows.Media.Media3D.Point3D p3d = new System.Windows.Media.Media3D.Point3D(np.x, np.y, np.z);
                System.Windows.Media.Media3D.Point3D jwh = Helpler.PointToJWH(p3d, distnet.scene.earthManager.earthpara);
                System.Windows.Point pnt = new System.Windows.Point(jwh.Y, jwh.X);
                if (distnet.scene.coordinateManager.Enable)
                {
                    pnt = distnet.scene.coordinateManager.transToOuter(pnt);                                          //若启用了坐标转换,转换为外部坐标
                }
                dot = new EDDot(elayer)
                {
                    id       = MyClassLibrary.helper.getGUID(),
                    location = pnt.ToString(),
                };
                dot.order  = idxmin + 1;
                dot.scaleX = dot.scaleY = dot.scaleZ = distnet.UnitMeasure * 5;
                elayer.AddObject(dot);
            }

            distnet.scene.UpdateModel();
        }
Example #9
0
        ///<summary>解析svg文件</summary>
        void loadFromSvg(string filename)
        {
            //示例从svg中读取非地理数据展现

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.ConformanceLevel = ConformanceLevel.Document;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments   = false;

            ;
            //settings.LineNumberOffset = 2;
            XmlReader reader = XmlReader.Create(filename, settings);
            string    elename;
            string    id, fill, stroke, width, height, data, layer, symbol, translate, rotate, scale, zclass, shapetype, layerid;

            id = layerid = "";
            int depth;

            //解析图元用
            bool            istext    = false;
            Brush           brush     = null;
            DrawingGroup    drawgroup = new DrawingGroup();
            GeometryDrawing aDrawing;

            WpfEarthLibrary.pSymbol psymbol = null;
            //层
            WpfEarthLibrary.pLayer player = null;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.CDATA)
                {
                    string   tmp = reader.Value;
                    string[] stringSeparators = new string[] { "\n" };
                    string[] ss = tmp.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string s in ss)
                    {
                        Regex regex = new Regex(".(.*?) {stroke:(.*?); fill:(.*?) }", RegexOptions.Multiline);
                        Match m     = regex.Match(s);
                        if (m.Success)
                        {
                            string stylename = m.Groups[1].Value;
                            stroke = m.Groups[2].Value;
                            fill   = m.Groups[3].Value;

                            //zh注:style暂未实现
                        }
                    }
                }

                if (reader.IsStartElement())
                {
                    elename = reader.Name;
                    switch (elename)
                    {
                    case "svg":      //  svg
                        string tmp2 = getPropertyValue(reader, "viewBox");
                        if (tmp2 != null)
                        {
                            Rect svgviewbox = Rect.Parse(tmp2);
                            uc.earthManager.planeViewBox = svgviewbox;     //必须设置,方能自动调整相机到适当位置,若显现看起来没居中,是图形与viewbox不完全匹配,可手动调整这个viewbox数值以居中
                        }
                        break;

                    case "symbol":      //  图元符号
                        depth = reader.Depth;
                        if (reader.HasAttributes)
                        {
                            string symbolid = getPropertyValue(reader, "id");
                            string viewbox  = getPropertyValue(reader, "viewBox");
                            reader.MoveToElement();

                            //开始一个图元的处理,创建一个图元对象并加入到uc.objmanager的图元字典中,以便框架生成公用材质供厂站使用,在本示例中,仅breakor使用到了公用图元
                            drawgroup = new DrawingGroup();
                            Rect symbolviewbox = new Rect(0, 0, 2, 2);
                            if (!string.IsNullOrWhiteSpace(viewbox))
                            {
                                symbolviewbox = Rect.Parse(viewbox);
                            }
                            psymbol = new pSymbol()
                            {
                                id = symbolid, name = symbolid, sizeX = symbolviewbox.Width, sizeY = symbolviewbox.Height
                            };
                            uc.objManager.zSymbols.Add(symbolid, psymbol);
                            istext = false;
                        }

                        while (reader.Read())
                        {
                            if (reader.Depth == depth && reader.NodeType == XmlNodeType.EndElement)
                            {
                                //结束一个图元处理,对图元的brush赋值
                                if (!istext)
                                {
                                    DrawingBrush myDrawingBrush = new DrawingBrush();
                                    myDrawingBrush.Drawing = drawgroup;
                                    psymbol.brush          = myDrawingBrush;
                                }

                                break;
                            }
                            switch (reader.Name)
                            {
                            case "circle":
                                if (reader.HasAttributes)
                                {
                                    fill   = getPropertyValue(reader, "fill");
                                    stroke = "rgb(0, 0, 0)";
                                    width  = getPropertyValue(reader, "stroke-width");
                                    data   = getPropertyValue(reader, "cx") + "," + getPropertyValue(reader, "cy") + "|" + getPropertyValue(reader, "r");
                                    reader.MoveToElement();
                                    //绘图元元素
                                    Regex regex = new Regex("(\\d*.?\\d*,\\d*.?\\d*)\\|(\\d*.?\\d*)", RegexOptions.Multiline);
                                    Match m     = regex.Match(data);
                                    if (m.Success)
                                    {
                                        Point  pc = Point.Parse(m.Groups[1].Value);
                                        double r  = double.Parse(m.Groups[2].Value);

                                        EllipseGeometry geo = new EllipseGeometry(pc, r, r);
                                        aDrawing          = new GeometryDrawing();
                                        aDrawing.Geometry = geo;

                                        Pen    pen       = new Pen();
                                        double thickness = double.Parse(width);
                                        thickness     = thickness < 2 ? 2 : thickness;
                                        pen.Thickness = thickness;
                                        //brush = ;//defaultbrush;//强制缺省用黄色//brush = anaBrush(item["fill"].ToString());
                                        brush        = new SolidColorBrush(Colors.Red);
                                        pen.Brush    = brush;
                                        aDrawing.Pen = pen;
                                        drawgroup.Children.Add(aDrawing);
                                    }
                                }
                                break;

                            case "ellipse":
                                if (reader.HasAttributes)
                                {
                                    fill   = getPropertyValue(reader, "fill");
                                    stroke = "rgb(0, 0, 0)";
                                    width  = getPropertyValue(reader, "stroke-width");
                                    double cx = double.Parse(getPropertyValue(reader, "cx"));
                                    double cy = double.Parse(getPropertyValue(reader, "cy"));
                                    double rx = double.Parse(getPropertyValue(reader, "rx"));
                                    double ry = double.Parse(getPropertyValue(reader, "ry"));

                                    reader.MoveToElement();
                                    //绘图元元素
                                    Point           pc  = new Point(cx, cy);
                                    EllipseGeometry geo = new EllipseGeometry(pc, rx, ry);
                                    aDrawing          = new GeometryDrawing();
                                    aDrawing.Geometry = geo;

                                    Pen    pen       = new Pen();
                                    double thickness = double.Parse(width);
                                    thickness     = thickness < 2 ? 2 : thickness;
                                    pen.Thickness = thickness;
                                    brush         = Brushes.Yellow;  //注,色彩应从fill取,示例没做转换,直接使用黄色
                                    pen.Brush     = brush;
                                    aDrawing.Pen  = pen;
                                    drawgroup.Children.Add(aDrawing);
                                }
                                break;

                            case "rect":
                                if (reader.HasAttributes)
                                {
                                    fill   = getPropertyValue(reader, "fill");
                                    stroke = "rgb(0, 0, 0)";
                                    width  = getPropertyValue(reader, "width");
                                    height = getPropertyValue(reader, "height");
                                    data   = getPropertyValue(reader, "cx") + "," + getPropertyValue(reader, "cy") + "|" + getPropertyValue(reader, "r");
                                    reader.MoveToElement();
                                    //绘图元元素
                                    RectangleGeometry geo = new RectangleGeometry();
                                    geo.Rect = new Rect(0, 0, double.Parse(width), double.Parse(height));

                                    aDrawing          = new GeometryDrawing();
                                    aDrawing.Geometry = geo;

                                    aDrawing.Brush = new SolidColorBrush(Colors.Aqua);
                                    drawgroup.Children.Add(aDrawing);
                                }
                                break;

                            case "path":
                                if (reader.HasAttributes)
                                {
                                    fill   = getPropertyValue(reader, "fill");
                                    stroke = "rgb(0, 0, 0)";
                                    width  = getPropertyValue(reader, "stroke-width");
                                    data   = getPropertyValue(reader, "d");
                                    reader.MoveToElement();
                                    //绘图元元素
                                    Geometry geo = PathGeometry.Parse(data);
                                    aDrawing          = new GeometryDrawing();
                                    aDrawing.Geometry = geo;

                                    brush          = Brushes.Orange;
                                    aDrawing.Brush = brush;
                                    Pen pen = new Pen();
                                    pen.Thickness = double.Parse(width);
                                    brush         = Brushes.Blue;
                                    pen.Brush     = brush;
                                    aDrawing.Pen  = pen;
                                    drawgroup.Children.Add(aDrawing);
                                }
                                break;

                            case "line":
                                if (reader.HasAttributes)
                                {
                                    //<line stroke="rgb(0, 0, 0)" stroke-width="1.000000" x1="50.000000" y1="7.499999" x2="13.193920" y2="71.250001" />
                                    stroke = getPropertyValue(reader, "stroke");
                                    width  = getPropertyValue(reader, "stroke-width");
                                    data   = string.Format("M {0} {1} L {2} {3}", getPropertyValue(reader, "x1"), getPropertyValue(reader, "y1"), getPropertyValue(reader, "x2"), getPropertyValue(reader, "y2"));
                                    reader.MoveToElement();
                                    //绘图元元素
                                }
                                break;

                            case "text":
                                if (reader.HasAttributes)
                                {
                                    stroke = getPropertyValue(reader, "stroke");


                                    reader.MoveToElement();
                                    //绘图元元素
                                    psymbol.brush = Brushes.SkyBlue;
                                    istext        = true;
                                }
                                break;
                            }
                        }
                        break;

                    case "g":
                        depth = reader.Depth;
                        if (reader.HasAttributes)
                        {
                            reader.MoveToAttribute("id");
                            layer = reader.Value;
                            reader.MoveToElement();

                            //开始一个层,在uc.objmanager中创建一个层
                            player = uc.objManager.AddLayer(layer, layer, layer);
                        }
                        while (reader.Read())
                        {
                            if (reader.Depth == depth && reader.NodeType == XmlNodeType.EndElement)
                            {
                                break;
                            }

                            if (reader.Name == "use" && reader.NodeType == XmlNodeType.Element)
                            {
                                shapetype = "dot";
                                id        = getPropertyValue(reader, "id");
                                fill      = getPropertyValue(reader, "fill");
                                stroke    = getPropertyValue(reader, "stroke");
                                symbol    = getPropertyValue(reader, "xlink:href");
                                zclass    = getPropertyValue(reader, "class");
                                //data = getPropertyValue(reader, "transform");
                                double x = double.Parse(getPropertyValue(reader, "x"));
                                double y = double.Parse(getPropertyValue(reader, "y"));
                                double w = double.Parse(getPropertyValue(reader, "width"));
                                double h = double.Parse(getPropertyValue(reader, "height"));
                                reader.MoveToElement();



                                //点类对象,此处示例代码假定点对象使用了图元
                                symbol = symbol.Replace("#", "");
                                double aspect = uc.objManager.zSymbols[symbol].sizeX / uc.objManager.zSymbols[symbol].sizeY;      //从图元取宽高比

                                pSymbolObject obj = new pSymbolObject(player)
                                {
                                    id            = id,
                                    name          = id,
                                    planeLocation = (new Point(x + w / 2, y + h / 2)).ToString(), //注:应赋值到planeLocation(平面坐标用),而不是location(经纬度坐标用),另外,校验位置到中心点
                                    symbolid      = symbol,
                                    scaleX        = 0.005f,                                       //  0.005为从svg平面空间到3D空间的缩放系数,可自行调整大小
                                    scaleY        = (float)(0.005 * aspect),
                                    color         = Colors.LightBlue,
                                    isH           = true
                                };
                                player.AddObject(id, obj);
                            }
                            else if (reader.Name == "path" && reader.NodeType == XmlNodeType.Element)
                            {
                                shapetype = "path";
                                id        = getPropertyValue(reader, "id");
                                fill      = getPropertyValue(reader, "fill");
                                stroke    = getPropertyValue(reader, "stroke");
                                width     = getPropertyValue(reader, "stroke-width");
                                data      = getPropertyValue(reader, "d");
                                zclass    = getPropertyValue(reader, "class");
                                reader.MoveToElement();

                                //线对象
                                if (!string.IsNullOrWhiteSpace(id))
                                {
                                    pPowerLine obj = new pPowerLine(player)
                                    {
                                        id        = id,
                                        name      = id,
                                        color     = Color.FromRgb(0xFF, 0x66, 0x00),
                                        isFlow    = true,   //是否显示潮流
                                        thickness = 0.002f, //线宽
                                        arrowSize = 0.005f  //潮流箭头大小
                                    };
                                    // 处理path短写,生成点集,对更复杂的短写,需借助path对象生成点集
                                    string tmp = data;
                                    tmp = tmp.Replace("M", "");
                                    string[] ps     = tmp.Split('L');
                                    string   points = "";
                                    int      idx    = 0;
                                    foreach (string s in ps)
                                    {
                                        if (idx != 0)
                                        {
                                            points += " ";
                                        }
                                        Point pt = Point.Parse(s);
                                        points += pt.ToString();
                                        idx++;
                                    }

                                    //zh注:对不合理的过近的相邻点进行处理,必须进行此步检查,否则在3D空间不能正常生成3D线条
                                    PointCollection pc    = PointCollection.Parse(points);
                                    PointCollection newpc = new PointCollection();
                                    newpc.Add(pc[0]);
                                    for (int i = 1; i < pc.Count; i++)
                                    {
                                        if ((pc[i] - pc[i - 1]).Length > 20)
                                        {
                                            if (i < pc.Count - 1)
                                            {
                                                Vector v1 = pc[i] - pc[i - 1]; v1.Normalize();
                                                Vector v2 = pc[i + 1] - pc[i]; v2.Normalize();
                                                if (v1 != v2)
                                                {
                                                    newpc.Add(pc[i]);
                                                }
                                            }
                                            else
                                            {
                                                newpc.Add(pc[i]);
                                            }
                                        }
                                    }
                                    (obj as pPowerLine).strPoints = newpc.ToString();

                                    obj.planeStrPoints = newpc.ToString();     // //注:应赋值到planeStrPoints,而不是strPoints
                                    if (newpc.Count > 1)
                                    {
                                        player.pModels.Add(id, obj);
                                    }


                                    //处理潮流,在本demo中,ConnectNode_Layer层中的线不显示潮流箭头
                                    if (player.id == "ConnectNode_Layer")
                                    {
                                        obj.isFlow = false;
                                    }
                                }
                            }
                            else if (reader.Name == "text" && reader.NodeType == XmlNodeType.Element)
                            {
                                stroke = getPropertyValue(reader, "stroke");
                                double x          = double.Parse(getPropertyValue(reader, "x"));
                                double y          = double.Parse(getPropertyValue(reader, "y"));
                                string fontfamily = getPropertyValue(reader, "font-family");
                                string fontsize   = getPropertyValue(reader, "font-size");
                                zclass = getPropertyValue(reader, "class");
                                reader.Read();
                                string text = reader.Value;

                                reader.MoveToElement();
                                if (text == "线")
                                {
                                }

                                //文字对象
                                double w       = 40; // w 和 h用来修正位置
                                double h       = -10;
                                float  scalexy = float.Parse(fontsize) / 16f * 0.8f;
                                if (player.id == "Text_Layer")
                                {
                                    pText obj = new pText(player)
                                    {
                                        id            = Helpler.getGUID(), //生成guid串,确保key值唯一
                                        name          = text,
                                        text          = text,
                                        planeLocation = (new Point(x + w / 2, y + h / 2)).ToString(), //注:应赋值到planeLocation(平面坐标用),而不是location(经纬度坐标用),另外,校验位置到中心点
                                        isH           = true,                                         //是否水平放置
                                        color         = Colors.White,
                                        scaleX        = scalexy,
                                        scaleY        = scalexy,
                                    };
                                    player.AddObject(text, obj);
                                }
                            }
                            else if (reader.Name == "rect" && reader.NodeType == XmlNodeType.Element)
                            {
                                fill   = getPropertyValue(reader, "fill");
                                stroke = getPropertyValue(reader, "stroke");
                                double x = double.Parse(getPropertyValue(reader, "x"));
                                double y = double.Parse(getPropertyValue(reader, "y"));
                                double w = double.Parse(getPropertyValue(reader, "width"));
                                double h = double.Parse(getPropertyValue(reader, "height"));

                                reader.Read();

                                reader.MoveToElement();

                                //厂站对象
                                if (player.id == "Other_Layer")
                                {
                                    pSymbolObject obj = new pSymbolObject(player)
                                    {
                                        id            = Helpler.getGUID(),                            //生成guid串,确保key值唯一
                                        planeLocation = (new Point(x + w / 2, y + h / 2)).ToString(), //注:应赋值到planeLocation(平面坐标用),而不是location(经纬度坐标用),另外,校验位置到中心点
                                        isH           = true,
                                        brush         = Brushes.White,
                                        color         = Colors.Red,
                                        scaleX        = (float)(w * 0.0005), //0.0005为映射到3D空间的尺寸调整系数
                                        scaleY        = (float)(h * 0.0005)
                                    };
                                    player.AddObject(obj.id, obj);
                                }
                            }
                        }

                        break;
                    }
                }
            }

            //==============清理空白层
            int idxi = 0;

            while (idxi < uc.objManager.zLayers.Count)
            {
                if (uc.objManager.zLayers.Values.ElementAt(idxi).pModels.Count == 0)
                {
                    uc.objManager.zLayers.Remove(uc.objManager.zLayers.Keys.ElementAt(idxi));
                }
                else
                {
                    idxi++;
                }
            }
        }