Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
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();
        }
Ejemplo 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;
            //}
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
        ///<summary>示例:显示区域</summary>
        void showArea(bool isShow)
        {
            //====================  载入区域测试  ======================
            //objManager.zLayers.Add("区县图层", new zLayer(objManager) { id = "区县图层", name = "区县图层" });  //zh注:按深度写,层加到前面,以后在层中加深度索引,立柱若有问题,再在对象中加深度索引
            pLayer           containerLayer;
            PowerBasicObject obj;

            if (isShow)
            {
                if (!uc.objManager.zLayers.TryGetValue("区县图层", out containerLayer))
                {
                    uc.objManager.AddLayer("区县图层", "区县图层", "区县图层");
                    containerLayer           = uc.objManager.zLayers["区县图层"];
                    containerLayer.deepOrder = -1;
                    foreach (DataRow item in dtshareobject.AsEnumerable().Where(p => p.Field <string>("layername") == "区县图层"))
                    {
                        obj = new pArea(containerLayer)
                        {
                            id        = item["bh"].ToString(),
                            name      = item["objname"].ToString(),
                            strPoints = item["points"].ToString(),
                            color     = Color.FromArgb(0x01, 0x00, 0x46, 0x5A)
                                        //areaColor = (Color)ColorConverter.ConvertFromString(item["fill"].ToString())
                        };

                        //处理颜色
                        Color    tmpcolor = Colors.AliceBlue;
                        string[] ss       = (item["fill"].ToString()).Split('|');
                        Dictionary <string, string> dic = new Dictionary <string, string>();
                        foreach (string se in ss)
                        {
                            string sn = se.Substring(0, se.IndexOf('='));
                            string sv = se.Substring(se.IndexOf('=') + 1);
                            dic.Add(sn, sv);
                        }
                        if (dic["type"] == "SolidColorBrush")
                        {
                            if (dic["string"].Contains('#'))
                            {
                                tmpcolor = (Color)ColorConverter.ConvertFromString(dic["string"]);//  (SolidColorBrush)(new System.Windows.Media.BrushConverter().ConvertFromString(dic["string"]));
                            }
                            else
                            {
                                string[] scolor = dic["string"].Split(',');
                                tmpcolor = Color.FromRgb(byte.Parse(scolor[0]), byte.Parse(scolor[1]), byte.Parse(scolor[2]));
                            }
                        }
                        tmpcolor.A           = 80;
                        (obj as pArea).color = tmpcolor;

                        containerLayer.pModels.Add(item["bh"].ToString(), obj);
                        //break;
                    }
                }
                containerLayer.logicVisibility = true;
            }
            else
            {
                if (uc.objManager.zLayers.TryGetValue("区县图层", out containerLayer))
                {
                    containerLayer.logicVisibility = false;
                }
            }

            uc.UpdateModel();
        }