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>
        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.º 3
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();
        }