Esempio n. 1
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;
            }
        }
Esempio n. 2
0
        void initContour()
        {
            if (!root.earth.objManager.zLayers.TryGetValue("负荷等值图层", out containerLayer))
            {
                root.earth.objManager.AddLayer("负荷等值图层", "负荷等值图层", "负荷等值图层");
                containerLayer = root.earth.objManager.zLayers["负荷等值图层"];
            }
            //=========
            double minx, miny, maxx, maxy;

            miny = dots.Min(p => p.location.X); maxy = dots.Max(p => p.location.X);  //将经度换为X坐标, 纬度换为Y坐标
            minx = dots.Min(p => p.location.Y); maxx = dots.Max(p => p.location.Y);
            double w = maxx - minx; double h = maxy - miny;

            minx = minx - w * 0.2; maxx = maxx + w * 0.2;
            miny = miny - h * 0.2; maxy = maxy + h * 0.2;
            w    = maxx - minx; h = maxy - miny;
            //经纬换为屏幕坐标
            int size = 1024;

            foreach (ContourGraph.ValueDot dot in dots)
            {
                dot.location = new Point((dot.location.Y - minx) / w * size, (maxy - dot.location.X) / h * size);  //重新赋与新的平面点位置, 注,纬度取反,仅适用北半球
            }
            double maxvalue = dots.Max(p => p.value);

            //设置计算参数
            con               = new ContourGraph.Contour();
            con.dots          = dots;
            con.opacityType   = ContourGraph.Contour.EOpacityType.正坡形;
            con.opacityRange  = 0.9;
            con.minOpacity    = 0.3;
            con.maxOpacity    = 1;
            con.canvSize      = new Size(size, size);
            con.gridXCount    = 200;
            con.gridYCount    = 200;
            con.Span          = 30;
            con.maxvalue      = maxvalue * 0.9;
            con.minvalue      = 0;
            con.dataFillValue = 0;
            con.dataFillMode  = ContourGraph.Contour.EFillMode.八角点包络填充;
            con.isDrawGrid    = false;
            con.isDrawLine    = false;
            con.isFillLine    = true;

            gcon = new pContour(containerLayer)
            {
                id = "负荷等值图"
            };                                                   // { minJD = minx, maxJD = maxx, minWD = miny, maxWD = maxy };
            gcon.setRange(minx, maxx, miny, maxy);
            gcon.brush = con.ContourBrush;
            containerLayer.AddObject("负荷等值图", gcon);

            con.GenCompleted += new EventHandler(con_GenCompleted);
            con.GenContourAsync(); //异步开始生成

            root.earth.UpdateModel();
        }
Esempio n. 3
0
        void showcontour(bool isShow)
        {
            if (isShow)
            {
                if (!root.earth.objManager.zLayers.TryGetValue("等高图层", out containerLayer))
                {
                    root.earth.objManager.AddLayer("等高图层", "等高图层", "等高图层");
                    containerLayer           = root.earth.objManager.zLayers["等高图层"];
                    containerLayer.deepOrder = -1;


                    //导入和重新计算点位置
                    pSymbolObject ps;
                    dots = new List <ContourGraph.ValueDot>();

                    IEnumerable <PowerBasicObject> tmpobjs = root.earth.objManager.getAllObjListBelongtoCategory("变压器");
                    foreach (PowerBasicObject obj in tmpobjs)//.Where(p => p.busiRunData != null))
                    {
                        ps = obj as pSymbolObject;
                        double tmpvalue = 0.85 + 0.3 * rd.NextDouble();//(ps.busiRunData as RunDataNodeP).voltPUV;
                        dots.Add(new ContourGraph.ValueDot()
                        {
                            id = obj.id, location = Point.Parse(ps.location), value = tmpvalue
                        });
                        objs.Add(ps.id, ps);
                        obj.busiData.busiValue1 = tmpvalue;                      //存储电压标幺值 , busiValue已被变电站负载占用
                        obj.busiData.busiValue2 = (tmpvalue - 0.85) / 0.3 * 100; //存储模板用位置信息,避免写转换
                        //更复杂应用应使用busiData自定义类来处理
                        obj.busiData.busiStr2 = tmpvalue.ToString("f2");
                    }
                    double minx, miny, maxx, maxy;
                    miny = dots.Min(p => p.location.X); maxy = dots.Max(p => p.location.X);  //将经度换为X坐标, 纬度换为Y坐标
                    minx = dots.Min(p => p.location.Y); maxx = dots.Max(p => p.location.Y);
                    double w = maxx - minx; double h = maxy - miny;
                    minx = minx - w * 0.2; maxx = maxx + w * 0.2;
                    miny = miny - h * 0.2; maxy = maxy + h * 0.2;
                    w    = maxx - minx; h = maxy - miny;
                    //经纬换为屏幕坐标
                    int size = 1024;
                    foreach (ContourGraph.ValueDot dot in dots)
                    {
                        dot.location = new Point((dot.location.Y - minx) / w * size, (maxy - dot.location.X) / h * size);  //重新赋与新的平面点位置, 注,纬度取反,仅适用北半球
                    }

                    //设置计算参数
                    con                  = new ContourGraph.Contour();
                    con.dots             = dots;
                    con.opacityType      = ContourGraph.Contour.EOpacityType.倒梯形;
                    con.canvSize         = new Size(size, size);
                    con.gridXCount       = 300;
                    con.gridYCount       = 300;
                    con.Span             = 30;
                    con.maxvalue         = 1.15;
                    con.minvalue         = 0.85;
                    con.dataFillValue    = 1;
                    con.dataFillMode     = ContourGraph.Contour.EFillMode.单点包络填充;
                    con.dataFillDictance = 100;
                    con.dataFillSpan     = 10;
                    con.isDrawGrid       = false;
                    con.isDrawLine       = false;
                    con.isFillLine       = true;
                    //con.isShowData = true;

                    //计算
                    //con.GenContour();
                    //创建图形
                    gcon = new pContour(containerLayer)
                    {
                        id = "等值图"
                    };                                                 // { minJD = minx, maxJD = maxx, minWD = miny, maxWD = maxy };
                    gcon.setRange(minx, maxx, miny, maxy);
                    gcon.brush = con.ContourBrush;
                    containerLayer.AddObject("等值线", gcon);

                    //contourtimer.Start();  //timer模拟刷新

                    con.GenCompleted += new EventHandler(con_GenCompleted);
                    con.GenContourAsync(); //异步开始生成
                }

                containerLayer.logicVisibility = true;
            }
            else
            {
                if (root.earth.objManager.zLayers.TryGetValue("等高图层", out containerLayer))
                {
                    containerLayer.logicVisibility = false;
                }
                //contourtimer.Stop();
            }
            root.earth.UpdateModel();
        }
Esempio n. 4
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;
            //}
        }
Esempio n. 5
0
        ///<summary>创建新对象</summary>
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            if (tree.SelectedItem != null)
            {
                DNDesc dnd = tree.SelectedItem as DNDesc;

                //处理对象的层
                pLayer           nlayer = distnet.addLayer(dnd.sort);
                PowerBasicObject obj    = dnd.CreateByType(nlayer);
                obj.id   = MyClassLibrary.helper.getGUID();
                obj.name = "新对象";

                //Point? pnttmp = distnet.scene.camera.getScreenCenterGeo();
                Point?pnttmp = distnet.scene.camera.getScreenCenter();

                if (pnttmp != null)
                {
                    Point pnt = (Point)pnttmp;
                    if (obj is pSymbolObject) //新增的图元
                    {
                        (obj as pSymbolObject).location = pnt.ToString();
                        PowerBasicObject refobj = distnet.findFirstObj(obj.GetType());
                        if (refobj != null)
                        {
                            (obj as pSymbolObject).scaleX = (refobj as pSymbolObject).scaleX;
                            (obj as pSymbolObject).scaleY = (refobj as pSymbolObject).scaleY;
                            (obj as pSymbolObject).scaleZ = (refobj as pSymbolObject).scaleZ;
                            (obj as pSymbolObject).color  = (refobj as pSymbolObject).color;
                            (obj as pSymbolObject).isH    = true;
                        }
                        obj.DBOPKey = dnd.dbopkey;
                        obj.createAcntData();
                        (obj.busiAccount as AcntDataBase).id   = obj.id;
                        (obj.busiAccount as AcntDataBase).name = obj.name;
                        nlayer.AddObject(obj);
                        //(obj as pSymbolObject).aniTwinkle.doCount = 10;
                        //(obj as pSymbolObject).aniTwinkle.isDoAni = true;
                        //(obj as pSymbolObject).AnimationBegin(pSymbolObject.EAnimationType.闪烁);
                        distnet.scene.UpdateModel();
                    }
                    else if (obj is pPowerLine)                     //新增的线路
                    {
                        if (distnet.scene.coordinateManager.Enable) //启用了坐标转换
                        {
                            (obj as pPowerLine).strPoints = String.Format("{0} {1}", pnt, new Point(pnt.X - 50, pnt.Y - 50));
                        }
                        else  //缺省的经纬坐标
                        {
                            (obj as pPowerLine).strPoints = String.Format("{0} {1}", pnt, new Point(pnt.X - 0.005, pnt.Y - 0.005));
                        }

                        PowerBasicObject refobj = distnet.findFirstObj(obj.GetType());

                        if (refobj != null)
                        {
                            (obj as pPowerLine).thickness  = (refobj as pPowerLine).thickness;
                            (obj as pPowerLine).color      = (refobj as pPowerLine).color;
                            (obj as pPowerLine).arrowColor = (refobj as pPowerLine).arrowColor;
                            (obj as pPowerLine).arrowSize  = (refobj as pPowerLine).arrowSize;
                        }
                        else
                        {
                            (obj as pPowerLine).thickness  = 0.1f;
                            (obj as pPowerLine).color      = Colors.Red;;
                            (obj as pPowerLine).arrowColor = Colors.Blue;
                            (obj as pPowerLine).arrowSize  = 0.2f;
                        }

                        obj.DBOPKey = dnd.dbopkey;
                        obj.createAcntData();
                        (obj.busiAccount as AcntDataBase).id   = obj.id;
                        (obj.busiAccount as AcntDataBase).name = obj.name;
                        nlayer.AddObject(obj);
                        //(obj as pSymbolObject).aniTwinkle.doCount = 10;
                        //(obj as pSymbolObject).aniTwinkle.isDoAni = true;
                        //(obj as pSymbolObject).AnimationBegin(pSymbolObject.EAnimationType.闪烁);
                        distnet.scene.UpdateModel();
                    }
                    else if (obj is pArea) //新增的区域
                    {
                        (obj as pArea).strPoints = String.Format("{0} {1} {2}", pnt, new Point(pnt.X - 0.005, pnt.Y - 0.005), new Point(pnt.X, pnt.Y - 0.005));
                        PowerBasicObject refobj = distnet.findFirstObj(obj.GetType());
                        if (refobj != null)
                        {
                            (obj as pArea).color = (refobj as pArea).color;
                        }
                        obj.DBOPKey = dnd.dbopkey;
                        obj.createAcntData();
                        (obj.busiAccount as AcntDataBase).id   = obj.id;
                        (obj.busiAccount as AcntDataBase).name = obj.name;
                        nlayer.AddObject(obj);
                        //(obj as pSymbolObject).aniTwinkle.doCount = 10;
                        //(obj as pSymbolObject).aniTwinkle.isDoAni = true;
                        //(obj as pSymbolObject).AnimationBegin(pSymbolObject.EAnimationType.闪烁);
                        distnet.scene.UpdateModel();
                    }
                    else
                    {
                        return; //提前返回
                    }
                    // 置界面
                    editobj               = obj;
                    obj.modifyStatus      = EModifyStatus.新增;
                    obj.color             = Colors.White;
                    isNewObject           = true;
                    pgAcnt.SelectedObject = editobj.busiAccount;

                    //btnCreate.IsEnabled = false;
                    btnDelete.IsEnabled = true;
                    btnSave.IsEnabled   = isModify = true;
                    //btnExit.IsEnabled = true;
                }
            }
        }
Esempio n. 6
0
        void init()
        {
            symbolkeys = root.earth.objManager.zSymbols.Values.Where(p => p.sort == "car").Select(p => p.id).ToList();
            int symcount = symbolkeys.Count;

            //模拟站桩
            rangelayer = root.earth.objManager.AddLayer("carrangelayer", "carrangelayer", "carrangelayer");
            carlayer   = root.earth.objManager.AddLayer("carlayer", "carlayer", "carlayer");
            Rect range = root.earth.objManager.getBounds();

            for (int i = 0; i < 30; i++)
            {
                int           tmpi = rd.Next(symcount);
                Point         loca = new Point(range.X + range.Width * rd.NextDouble(), range.Y + range.Height * rd.NextDouble());
                pSymbolObject nobj = new pSymbolObject(carlayer)
                {
                    id       = "car" + i,
                    name     = "充电站" + i,
                    symbolid = symbolkeys[tmpi],
                    location = loca.ToString(),
                    isH      = true,
                    scaleX   = 0.0025f,
                    scaleY   = 0.0025f,
                    color    = Color.FromRgb(0xFF, 0x66, 0x00)
                };
                if (nobj.busiData == null)
                {
                    nobj.busiData = new busiBase(nobj);
                }
                nobj.busiData.busiValue1   = (5 + rd.Next(6));                    //覆盖半径
                nobj.busiData.busiStr1     = symbolkeys[tmpi];                    //名称
                nobj.busiData.busiDatetime = DateTime.Now.AddDays(rd.Next(2000)); //投运时间
                nobj.busiData.busiSort     = "充电桩";
                nobj.busiData.busiBrush    = root.earth.objManager.zSymbols[nobj.symbolid].brush;
                carlayer.AddObject(nobj.id, nobj);
                //台账
                AccountCar acc = new AccountCar()
                {
                    id      = nobj.id,
                    name    = nobj.name,
                    address = "A区B街",
                    cap     = 100 * (1 + rd.Next(10)),
                    frhour  = 3 + rd.Next(10),
                    geo     = nobj.location,
                    nums    = 1 + rd.Next(5),
                    ptype   = nobj.busiData.busiStr1,
                    rad     = 2 + rd.Next(10),
                    rcmode  = (AccountCar.Ertype)rd.Next(3),
                    rdate   = DateTime.Now.AddDays(100 + rd.Next(8000)).ToString("yyyy年MM月"),
                    region  = "某区",
                    rmode   = (AccountCar.Ermode)rd.Next(4),
                    vl      = 380
                };
                nobj.busiAccount = acc;



                //范围
                pSymbolObject robj = new pSymbolObject(rangelayer)
                {
                    id         = i + "carrange",
                    symbolid   = "充电桩覆盖范围",
                    location   = loca.ToString(),
                    isH        = true,
                    isUseColor = false
                };
                robj.scaleX = robj.scaleY = (float)(nobj.busiData.busiValue1 / 100);
                if (robj.busiData == null)
                {
                    robj.busiData = new busiBase(robj);
                }
                robj.busiData.busiSort = "覆盖范围";

                rangelayer.AddObject(robj.id, robj);
            }
            root.earth.UpdateModel();


            //初始化图例
            lstType.ItemsSource = root.earth.objManager.zSymbols.Values.Where(p => p.sort == "car");
            //分类占比
            cht.DataSource = from e0 in root.earth.objManager.getObjList("充电桩")
                             group e0 by e0.busiData.busiStr1 into g
                             select new
            {
                argu  = g.Key,
                value = g.Count()
            };

            lstObj.ItemsSource = root.earth.objManager.getObjList("充电桩");
        }