public bool IsValid(object caller, ICSharpCode.Core.Condition condition)
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return(false);
            }
            if (CommonUtils.Instance().CurEditLayer != null)
            {
                DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer;
                if (dffc != null)
                {
                    string facType = dffc.GetFacilityClassName();
                    if (facType != "PipeLine" && facType != "PipeNode" && facType != "PipeBuild" && facType != "PipeBuild1")
                    {
                        IFeatureLayer fl = dffc.GetFeatureLayer();
                        if (fl != null)
                        {
                            if (fl.GeometryType == gviGeometryColumnType.gviGeometryColumnPoint)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
        public bool IsValid(object caller, ICSharpCode.Core.Condition condition)
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return(false);
            }
            if (CommonUtils.Instance().CurEditLayer != null)
            {
                DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer;
                if (dffc != null)
                {
                    string facType = dffc.GetFacilityClassName();
                    if (facType != null && facType == "PipeNode")
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 3
0
  public bool IsValid(object caller, ICSharpCode.Core.Condition condition)
 {
     DF3DApplication app = DF3DApplication.Application;
     if (app == null || app.Current3DMapControl == null) return false;
     int count = SelectCollection.Instance().GetCount(false);
     bool bCount = count > 0;
     bool bFacility = false; 
     if (CommonUtils.Instance().CurEditLayer != null)
     {
         DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer;
         if (dffc != null)
         {
             string str = dffc.GetFacilityClassName();
             if (!string.IsNullOrEmpty(str))
             {
                 if (str == "PipeLine" || str == "PipeNode" || str == "PipeBuild" || str == "PipeBuild1")
                 {
                     bFacility = true;
                 }
             }
         }
     }
     return bCount && bFacility;
 }
Exemplo n.º 4
0
        private void SpatialQuery()
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }

            try
            {
                HashMap        hashMap = new HashMap();
                IRowBuffer     buffer  = null;
                IFdeCursor     cursor  = null;
                ISpatialFilter filter  = null;
                IGeometry      geo2D   = this._drawTool.GetGeo();
                if (geo2D != null && geo2D.GeometryType == gviGeometryType.gviGeometryPolygon)
                {
                    IPolygon polygon = geo2D as IPolygon;
                    if (polygon != null)
                    {
                        DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer;
                        if (featureClassInfo != null)
                        {
                            IFeatureClass featureClass = featureClassInfo.GetFeatureClass();
                            if (featureClass != null)
                            {
                                string typeName = featureClassInfo.GetFacilityClassName();
                                if (typeName == "PipeLine" || typeName == "PipeNode" || typeName == "PipeBuild" || typeName == "PipeBuild1")
                                {
                                    filter = new SpatialFilterClass
                                    {
                                        GeometryField = "Shape",
                                        SpatialRel    = gviSpatialRel.gviSpatialRelIntersects,
                                        Geometry      = polygon.Clone2(gviVertexAttribute.gviVertexAttributeNone)
                                    };
                                }
                                else
                                {
                                    filter = new SpatialFilterClass
                                    {
                                        Geometry      = polygon,
                                        GeometryField = "Geometry",
                                        SpatialRel    = gviSpatialRel.gviSpatialRelEnvelope
                                    };
                                }
                                filter.SubFields = featureClass.FidFieldName;
                                cursor           = featureClass.Search(filter, true);
                                while ((buffer = cursor.NextRow()) != null)
                                {
                                    int featureId = int.Parse(buffer.GetValue(0).ToString());
                                    if (hashMap.Contains(featureClassInfo))
                                    {
                                        System.Collections.Generic.List <int> list = hashMap[featureClassInfo] as System.Collections.Generic.List <int>;
                                        if (!list.Contains(featureId))
                                        {
                                            list.Add(featureId);
                                        }
                                    }
                                    else
                                    {
                                        System.Collections.Generic.List <int> list2 = new System.Collections.Generic.List <int>();
                                        if (!list2.Contains(featureId))
                                        {
                                            list2.Add(featureId);
                                        }
                                        hashMap[featureClassInfo] = list2;
                                    }
                                }
                            }
                        }
                    }
                    SelectCollection.Instance().UpdateSelection(hashMap);
                    RenderControlEditServices.Instance().SetEditorPosition(SelectCollection.Instance().FcRowBuffersMap);
                    this.Clear();
                }
                if (buffer != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(buffer);
                }
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                }
                if (filter != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(filter);
                }
            }
            catch (Exception ex)
            {
                LoggingService.Error(ex.Message);
            }
        }
Exemplo n.º 5
0
        public override void Run(object sender, EventArgs e)
        {
            try
            {
                app = DF3DApplication.Application;
                if (app == null || app.Current3DMapControl == null)
                {
                    return;
                }
                this._geoFact = new GeometryFactory();
                Map3DCommandManager.Push(this);
                DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer;
                if (dffc != null)
                {
                    this._facType         = dffc.GetFacilityClassName();
                    _strGeometryFieldName = "";
                    if (this._facType == "PipeLine" || this._facType == "PipeNode" || this._facType == "PipeBuild" || this._facType == "PipeBuild1")
                    {
                        _strGeometryFieldName = "Shape";
                    }
                    else
                    {
                        IFeatureLayer fl = dffc.GetFeatureLayer();
                        if (fl != null)
                        {
                            _strGeometryFieldName = fl.GeometryFieldName;
                        }
                    }
                    if (!string.IsNullOrEmpty(_strGeometryFieldName))
                    {
                        IFeatureClass fc = dffc.GetFeatureClass();
                        if (fc != null)
                        {
                            IFieldInfoCollection fiCol = fc.GetFields();
                            int index = fiCol.IndexOf(_strGeometryFieldName);
                            if (index != -1)
                            {
                                IFieldInfo fi = fiCol.Get(index);
                                if (fi.GeometryDef != null)
                                {
                                    this._geoType = fi.GeometryDef.GeometryColumnType;
                                }
                            }
                        }
                        switch (this._geoType)
                        {
                        case gviGeometryColumnType.gviGeometryColumnModelPoint:
                            //添加方式:1、鼠标添加;2、文件添加
                            FrmInsertModel dlg = new FrmInsertModel();
                            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                string filePath = dlg.FilePath;
                                string ext      = Path.GetExtension(filePath);
                                if (File.Exists(filePath))
                                {
                                    int insertType = dlg.InsertType;
                                    if (insertType == 0 && ext.ToLower() == ".osg")
                                    {
                                        this._drawTool = DrawToolService.Instance.CreateDrawTool(DrawType._3DModel);
                                        if (this._drawTool != null)
                                        {
                                            (this._drawTool as Draw3DModel).Set3DModelFilePath(filePath);
                                            this._drawTool.OnStartDraw    += new OnStartDraw(this.OnStartDraw);
                                            this._drawTool.OnFinishedDraw += new OnFinishedDraw(this.OnFinishedDraw);
                                            this._drawTool.Start();
                                        }
                                    }
                                    else if (insertType == 1 && ext.ToLower() == ".xml")
                                    {
                                    }
                                }
                            }
                            break;

                        case gviGeometryColumnType.gviGeometryColumnPoint:
                            if (this._facType == "PipeNode")
                            {    // 添加附属设施或者管点
                            }
                            else
                            {    // 添加点
                                this._drawTool = DrawToolService.Instance.CreateDrawTool(DrawType.Point);
                                if (this._drawTool != null)
                                {
                                    this._drawTool.OnStartDraw    += new OnStartDraw(this.OnStartDraw);
                                    this._drawTool.OnFinishedDraw += new OnFinishedDraw(this.OnFinishedDraw);
                                    this._drawTool.Start();
                                }
                            }
                            break;

                        case gviGeometryColumnType.gviGeometryColumnPolyline:
                            if (this._facType == "PipeLine" || this._facType == "PipeBuild" || this._facType == "PipeBuild1")
                            {    // 选择管线或辅助样式
                            }
                            else
                            {    // 添加线
                                this._drawTool = DrawToolService.Instance.CreateDrawTool(DrawType.Polyline);
                                if (this._drawTool != null)
                                {
                                    this._drawTool.OnStartDraw    += new OnStartDraw(this.OnStartDraw);
                                    this._drawTool.OnFinishedDraw += new OnFinishedDraw(this.OnFinishedDraw);
                                    this._drawTool.Start();
                                }
                            }
                            break;

                        case gviGeometryColumnType.gviGeometryColumnPolygon:
                            if (this._facType == "PipeBuild" || this._facType == "PipeBuild1")
                            {    // 选择管线辅助样式
                            }
                            else
                            {    // 添加面
                                this._drawTool = DrawToolService.Instance.CreateDrawTool(DrawType.Polygon);
                                if (this._drawTool != null)
                                {
                                    this._drawTool.OnStartDraw    += new OnStartDraw(this.OnStartDraw);
                                    this._drawTool.OnFinishedDraw += new OnFinishedDraw(this.OnFinishedDraw);
                                    this._drawTool.Start();
                                }
                            }
                            break;

                        default:
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
        }
Exemplo n.º 6
0
        private void ClickQuery()
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            try
            {
                IFeatureLayer fl = this._drawTool.GetSelectFeatureLayerPickResult().FeatureLayer;
                if (fl == null)
                {
                    return;
                }
                int           featureId = this._drawTool.GetSelectFeatureLayerPickResult().FeatureId;
                FacilityClass facc      = Dictionary3DTable.Instance.GetFacilityClassByDFFeatureClassID(fl.FeatureClassId.ToString());
                if (facc == null || facc.Name != "PipeNode")
                {
                    XtraMessageBox.Show("您选中的不是管点设施,请选择管点设施。", "提示");
                    return;
                }
                DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fl.FeatureClassId.ToString());
                if (dffc == null || dffc.GetFeatureClass() == null)
                {
                    return;
                }
                IFeatureClass fc = dffc.GetFeatureClass();
                if (this._bFinished)
                {
                    Clear();
                    this._startFCGuid = fc.Guid.ToString();
                    this._startOid    = featureId;
                    this._bFinished   = false;

                    ILabel label = app.Current3DMapControl.ObjectManager.CreateLabel(app.Current3DMapControl.ProjectTree.RootID);
                    label.Text = "起点";
                    ITextSymbol ts = new TextSymbol();
                    ts.TextAttribute.TextSize  = SystemInfo.Instance.TextSize;
                    ts.TextAttribute.TextColor = Convert.ToUInt32(SystemInfo.Instance.TextColor, 16);
                    label.TextSymbol           = ts;
                    label.Position             = this._drawTool.GetSelectPoint();
                    this._listRGuid.Add(label.Guid);
                }
                else
                {
                    if (this._startFCGuid == fc.Guid.ToString() && this._startOid == featureId)
                    {
                        XtraMessageBox.Show("您选中的是同一个管点设施。", "提示");
                        return;
                    }
                    this._bFinished = true;
                    ILabel label = app.Current3DMapControl.ObjectManager.CreateLabel(app.Current3DMapControl.ProjectTree.RootID);
                    label.Text = "终点";
                    ITextSymbol ts = new TextSymbol();
                    ts.TextAttribute.TextSize  = SystemInfo.Instance.TextSize;
                    ts.TextAttribute.TextColor = Convert.ToUInt32(SystemInfo.Instance.TextColor, 16);
                    label.TextSymbol           = ts;
                    label.Position             = this._drawTool.GetSelectPoint();
                    this._listRGuid.Add(label.Guid);
                    if (this._startFCGuid != fc.Guid.ToString())
                    {
                        XtraMessageBox.Show("您选中的不是同一类管点设施。", "提示");
                        return;
                    }
                    else
                    {
                        WaitForm.Start("正在分析...", "请稍后");
                        FacClassReg reg = FacilityInfoService.GetFacClassRegByFeatureClassID(fc.Guid.ToString());
                        if (reg == null)
                        {
                            return;
                        }
                        TopoClass tc = FacilityInfoService.GetTopoClassByFacClassCode(reg.FacClassCode);
                        if (tc == null)
                        {
                            return;
                        }
                        TopoNetwork net = tc.GetNetwork();
                        if (net == null)
                        {
                            XtraMessageBox.Show("构建拓扑网络失败!", "提示");
                            return;
                        }
                        else
                        {
                            string        startId = this._startFCGuid + "_" + this._startOid.ToString();
                            string        endId   = fc.Guid.ToString() + "_" + featureId.ToString();
                            List <string> path;
                            double        shortestLength = net.SPFA(startId, endId, out path);
                            if ((shortestLength > 0.0 && shortestLength != double.MaxValue) || (path != null && path.Count > 0))
                            {
                                List <IPoint> listPt = new List <IPoint>();
                                foreach (string nodeId in path)
                                {
                                    int              index    = nodeId.LastIndexOf("_");
                                    string           fcguid   = nodeId.Substring(0, index);
                                    string           oid      = nodeId.Substring(index + 1, nodeId.Length - index - 1);
                                    DF3DFeatureClass dffcTemp = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fcguid);
                                    if (dffcTemp == null || dffcTemp.GetFeatureClass() == null)
                                    {
                                        continue;
                                    }
                                    if (dffcTemp.GetFacilityClassName() != "PipeNode")
                                    {
                                        continue;
                                    }
                                    IQueryFilter filter = new QueryFilter();
                                    filter.WhereClause = "oid = " + oid;
                                    filter.SubFields   = "oid,Shape";
                                    IRowBuffer row    = null;
                                    IFdeCursor cursor = null;
                                    try
                                    {
                                        cursor = dffcTemp.GetFeatureClass().Search(filter, false);
                                        while ((row = cursor.NextRow()) != null)
                                        {
                                            if (!row.IsNull(1) && (row.GetValue(1) is IGeometry))
                                            {
                                                IGeometry geo = row.GetValue(1) as IGeometry;
                                                switch (geo.GeometryType)
                                                {
                                                case gviGeometryType.gviGeometryPoint:
                                                    IPoint pt = geo as IPoint;
                                                    pt.Z = pt.Z + 1;
                                                    listPt.Add(pt);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                    finally
                                    {
                                        if (cursor != null)
                                        {
                                            System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                                            cursor = null;
                                        }
                                        if (row != null)
                                        {
                                            System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                                            row = null;
                                        }
                                    }
                                }
                                IPolyline polyline = (new GeometryFactory()).CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
                                foreach (IPoint pt in listPt)
                                {
                                    ISimplePointSymbol ps = new SimplePointSymbol();
                                    ps.Size      = 5;
                                    ps.Style     = gviSimplePointStyle.gviSimplePointCircle;
                                    ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16);
                                    IRenderPoint rp = app.Current3DMapControl.ObjectManager.CreateRenderPoint(pt, ps, app.Current3DMapControl.ProjectTree.RootID);
                                    rp.Glow(5000);
                                    polyline.AppendPoint(pt);
                                    this._listRGuid.Add(rp.Guid);
                                }
                                ICurveSymbol cs = new CurveSymbol();
                                cs.Color = Convert.ToUInt32(SystemInfo.Instance.LineColor, 16);
                                cs.Width = -5;
                                IRenderPolyline rpl = app.Current3DMapControl.ObjectManager.CreateRenderPolyline(polyline, cs, app.Current3DMapControl.ProjectTree.RootID);
                                rpl.Glow(5000);
                                this._listRGuid.Add(rpl.Guid);
                            }
                            else
                            {
                                XtraMessageBox.Show("两点不连通!", "提示");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("分析出错!", "提示");
            }
            finally
            {
                WaitForm.Stop();
            }
        }