private void CreateRenderPolyline(IPoint point) { if (gfactory == null) { gfactory = new GeometryFactory(); } fde_polyline = (IPolyline)gfactory.CreateGeometry(i3dGeometryType.i3dGeometryPolyline, i3dVertexAttribute.i3dVertexAttributeZ); fde_polyline.SpatialCRS = crs; fde_point = (IPoint)gfactory.CreateGeometry(i3dGeometryType.i3dGeometryPoint, i3dVertexAttribute.i3dVertexAttributeZ); fde_point.SpatialCRS = crs; fde_point.SetCoords(point.X, point.Y, point.Z, 0, 0); fde_polyline.AppendPoint(fde_point); fde_point.SetCoords(point.X + 20, point.Y, point.Z, 0, 0); fde_polyline.AppendPoint(fde_point); fde_point.SetCoords(point.X + 20, point.Y + 20, point.Z, 0, 0); fde_polyline.AppendPoint(fde_point); fde_point.SetCoords(point.X + 20, point.Y + 20, point.Z + 20, 0, 0); fde_polyline.AppendPoint(fde_point); lineSymbol = new CurveSymbolClass(); lineSymbol.Color = 0xffff00ff; // 紫红色 rpolyline = _axRenderControl.ObjectManager.CreateRenderPolyline(fde_polyline, lineSymbol); _axRenderControl.Camera.FlyToObject(rpolyline.Guid, i3dActionCode.i3dActionFlyTo); }
private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { DevExpress.XtraEditors.Controls.EditorButton btn = e.Button; switch (btn.Caption) { case "定位": DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } int focusedRowHandle = this.gridView1.FocusedRowHandle; if (focusedRowHandle == -1) { return; } DataRow dr = this.gridView1.GetDataRow(focusedRowHandle); if (dr["geo"] != null && dr["Name"] != null && dr["fcName"] != null && dr["fc"] != null) { ISurfaceSymbol ss = new SurfaceSymbolClass(); ss.Color = 0xcc00ff00; ICurveSymbol cs = new CurveSymbolClass(); cs.Color = 0xff00ff00; cs.Width = -5; ss.BoundarySymbol = cs; ISimplePointSymbol ps = new SimplePointSymbol(); ps.Size = SystemInfo.Instance.SymbolSize; ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16); IGeometry objGeo = dr["geo"] as IGeometry; if (objGeo.GeometryType == gviGeometryType.gviGeometryModelPoint) { IModelPoint mp = objGeo as IModelPoint; IModelPointSymbol mps = new ModelPointSymbol(); mps.SetResourceDataSet((dr["fc"] as IFeatureClass).FeatureDataSet); mps.Color = 0xffffff00; IRenderModelPoint rMP = app.Current3DMapControl.ObjectManager.CreateRenderModelPoint(mp, mps, app.Current3DMapControl.ProjectTree.RootID); rMP.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rMP.Guid, 8000); IGeometryFactory geoFact = new GeometryFactory(); IPoint pt = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pt.X = mp.X; pt.Y = mp.Y; pt.Z = mp.Z; ITableLabel tl = DrawTool.CreateTableLabel1(1); tl.TitleText = dr["fcName"].ToString(); tl.SetRecord(0, 0, dr["Name"].ToString()); tl.Position = pt; this._listRender.Add(tl.Guid); app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo); } } break; } }
private void DrawSightLine() { ClearSightLine(); ClearRes(); IPoint ptStart = this._geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); ptStart.X = (double)this.seObserX.Value; ptStart.Y = (double)this.seObserY.Value; ptStart.Z = (double)this.seObserZ.Value + (double)this.seObserZOff.Value; IPoint ptEnd = this._geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); ptEnd.X = (double)this.seObjX.Value; ptEnd.Y = (double)this.seObjY.Value; ptEnd.Z = (double)this.seObjZ.Value + (double)this.seObjZOff.Value; IPolyline line = this._geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline; line.AppendPoint(ptStart); line.AppendPoint(ptEnd); ICurveSymbol cs = new CurveSymbolClass(); cs.Color = 0xff00ff00; cs.Width = -1; this._rLine = this._3DControl.ObjectManager.CreateRenderPolyline(line, cs, this._3DControl.ProjectTree.RootID); }
private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { DevExpress.XtraEditors.Controls.EditorButton btn = e.Button; switch (btn.Caption) { case "定位": DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } int focusedRowHandle = this.gridView1.FocusedRowHandle; if (focusedRowHandle == -1) { return; } DataRow dr = this.gridView1.GetDataRow(focusedRowHandle); if (dr["geo"] != null && dr["Name"] != null && dr["fcName"] != null) { ISurfaceSymbol ss = new SurfaceSymbolClass(); ss.Color = 0xcc00ff00; ICurveSymbol cs = new CurveSymbolClass(); cs.Color = 0xff00ff00; cs.Width = -5; ss.BoundarySymbol = cs; ISimplePointSymbol ps = new SimplePointSymbol(); ps.Size = SystemInfo.Instance.SymbolSize; ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16); IGeometry objGeo = dr["geo"] as IGeometry; IPoint pt = null; if (objGeo.GeometryType == gviGeometryType.gviGeometryMultiPolyline) { double x = 0; double y = 0; double z = 0; IMultiPolyline mPolyline = objGeo as IMultiPolyline; for (int m = 0; m < mPolyline.GeometryCount; m++) { IPolyline polyline = mPolyline.GetPolyline(m); IPoint pttemp = polyline.Midpoint; x += pttemp.X; y += pttemp.Y; z += pttemp.Z; } x = x / mPolyline.GeometryCount; y = y / mPolyline.GeometryCount; z = z / mPolyline.GeometryCount; pt = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pt.X = x; pt.Y = y; pt.Z = z; IRenderMultiPolyline rMPolyline = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolyline(mPolyline, cs, app.Current3DMapControl.ProjectTree.RootID); rMPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything; rMPolyline.Glow(8000); this._listRender.Add(rMPolyline.Guid); } else if (objGeo.GeometryType == gviGeometryType.gviGeometryMultiPolygon) { double x = 0; double y = 0; double z = 0; IMultiPolygon mPolygon = objGeo as IMultiPolygon; for (int m = 0; m < mPolygon.GeometryCount; m++) { IPolygon polygon = mPolygon.GetPolygon(m); IPoint pttemp = polygon.Centroid; x += pttemp.X; y += pttemp.Y; z += pttemp.Z; } x = x / mPolygon.GeometryCount; y = y / mPolygon.GeometryCount; z = z / mPolygon.GeometryCount; pt = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pt.X = x; pt.Y = y; pt.Z = z; IRenderMultiPolygon rMPolygon = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolygon(mPolygon, ss, app.Current3DMapControl.ProjectTree.RootID); rMPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything; rMPolygon.Glow(8000); this._listRender.Add(rMPolygon.Guid); } else if (objGeo.GeometryType == gviGeometryType.gviGeometryPolyline) { IPolyline polyline = objGeo as IPolyline; pt = polyline.Midpoint; IRenderPolyline rPolyline = app.Current3DMapControl.ObjectManager.CreateRenderPolyline(polyline, cs, app.Current3DMapControl.ProjectTree.RootID); rPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything; rPolyline.Glow(8000); this._listRender.Add(rPolyline.Guid); } else if (objGeo.GeometryType == gviGeometryType.gviGeometryPoint) { IPoint point = objGeo as IPoint; pt = point; IRenderPoint rPoint = app.Current3DMapControl.ObjectManager.CreateRenderPoint(point, ps, app.Current3DMapControl.ProjectTree.RootID); rPoint.Glow(8000); this._listRender.Add(rPoint.Guid); } else if (objGeo.GeometryType == gviGeometryType.gviGeometryPolygon) { IPolygon polygon = objGeo as IPolygon; pt = polygon.Centroid; IRenderPolygon rPolygon = app.Current3DMapControl.ObjectManager.CreateRenderPolygon(polygon, ss, app.Current3DMapControl.ProjectTree.RootID); rPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything; rPolygon.Glow(8000); this._listRender.Add(rPolygon.Guid); } else { return; } ITableLabel tl = DrawTool.CreateTableLabel1(1); tl.TitleText = dr["fcName"].ToString(); tl.SetRecord(0, 0, dr["Name"].ToString()); tl.Position = pt; this._listRender.Add(tl.Guid); app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo); } break; } }
private void _3DControl_RcMouseClickSelect(object sender, _IRenderControlEvents_RcMouseClickSelectEvent e) { try { if (e.intersectPoint != null) { IPoint pt1 = this._geoFactory.CreateGeometry(gviGeometryType.gviGeometryPoint, gviVertexAttribute.gviVertexAttributeZ) as IPoint; pt1.X = e.intersectPoint.X; pt1.Y = e.intersectPoint.Y; pt1.Z = e.intersectPoint.Z; if (e.eventSender == gviMouseSelectMode.gviMouseSelectClick) { if (!this._isStarted) { this.Close(); if (this._onStartDraw != null) { this._onStartDraw(); } this._polygon = this._geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; this._polygon.ExteriorRing.AppendPoint(pt1); IPoint pt2 = pt1.Clone() as IPoint; pt2.X += 0.015; this._polygon.ExteriorRing.AppendPoint(pt2); ISurfaceSymbol ss = new SurfaceSymbolClass(); ss.Color = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16); ICurveSymbol cs = new CurveSymbolClass(); cs.Color = Convert.ToUInt32(SystemInfo.Instance.LineColor, 16); ss.BoundarySymbol = cs; _rPolygon = this._3DControl.ObjectManager.CreateRenderPolygon(this._polygon, ss, this._3DControl.ProjectTree.RootID); _rPolygon.HeightStyle = this._heightStyle; //this._polygon.ExteriorRing.Close(); this._isStarted = true; this._isFinished = false; } else { this._polygon.ExteriorRing.AppendPoint(pt1); this._polygon.ExteriorRing.Close(); this._rPolygon.SetFdeGeometry(this._polygon); } } else if (e.eventSender == gviMouseSelectMode.gviMouseSelectMove) { if (_rPoint != null) { this._objectManager.DeleteObject(_rPoint.Guid); System.Runtime.InteropServices.Marshal.ReleaseComObject(_rPoint); _rPoint = null; } _rPoint = this._objectManager.CreateRenderPoint(pt1, this._simplePointSymbol, this._rootID); if (this._isStarted) { this._polygon.ExteriorRing.UpdatePoint(this._polygon.ExteriorRing.PointCount - 1, pt1); this._rPolygon.SetFdeGeometry(this._polygon); } } } } catch (Exception ex) { LoggingService.Error(ex.Message + "\r\n" + ex.StackTrace); } }
private void _3DControl_RcMouseClickSelect(object sender, Gvitech.CityMaker.Controls._IRenderControlEvents_RcMouseClickSelectEvent e) { try { if (e.intersectPoint != null) { IPoint pt1 = this._geoFactory.CreateGeometry(gviGeometryType.gviGeometryPoint, gviVertexAttribute.gviVertexAttributeZ) as IPoint; pt1.X = e.intersectPoint.X; pt1.Y = e.intersectPoint.Y; pt1.Z = e.intersectPoint.Z; if (e.eventSender == gviMouseSelectMode.gviMouseSelectClick) { if (!this._isStarted) { this.Close(); if (this._onStartDraw != null) { this._onStartDraw(); } if (_polyline != null) { _polyline = null; } startPoint = pt1; double radius = 0.0000001; this._geo = (startPoint as ITopologicalOperator2D).Buffer2D(radius, gviBufferStyle.gviBufferCapround); ISurfaceSymbol ss = new SurfaceSymbolClass(); ss.Color = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16); ICurveSymbol cs = new CurveSymbolClass(); cs.Color = Convert.ToUInt32(SystemInfo.Instance.LineColor, 16); ss.BoundarySymbol = cs; _rPolygon = this._3DControl.ObjectManager.CreateRenderPolygon(this._geo as IPolygon, ss, this._3DControl.ProjectTree.RootID); _rPolygon.HeightStyle = this._heightStyle; _polyline = this._geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline; _polyline.AppendPoint(pt1); IPoint pt2 = pt1.Clone() as IPoint; pt2.X += 0.000001; _polyline.AppendPoint(pt2); _rPolyline = this._3DControl.ObjectManager.CreateRenderPolyline(_polyline, cs, this._3DControl.ProjectTree.RootID); _label = this._3DControl.ObjectManager.CreateLabel(this._3DControl.ProjectTree.RootID); _label.Position = _polyline.Midpoint; _label.Text = _polyline.Length.ToString("0.00") + " 米"; ITextSymbol ts = new TextSymbolClass(); TextAttribute ta = new TextAttribute(); ta.TextColor = Convert.ToUInt32(SystemInfo.Instance.TextColor, 16); ta.TextSize = SystemInfo.Instance.TextSize; ts.TextAttribute = ta; _label.TextSymbol = ts; this._isStarted = true; this._isFinished = false; } else { //this.End(); this._isStarted = false; this._isFinished = true; _polyline.UpdatePoint(1, pt1); _rPolyline.SetFdeGeometry(_polyline); _label.Position = _polyline.Midpoint; _label.Text = _polyline.Length.ToString("0.00") + " 米"; double radius = Math.Sqrt((startPoint.X - pt1.X) * (startPoint.X - pt1.X) + (startPoint.Y - pt1.Y) * (startPoint.Y - pt1.Y) + (startPoint.Z - pt1.Z) * (startPoint.Z - pt1.Z)); this._geo = (startPoint as ITopologicalOperator2D).Buffer2D(radius, gviBufferStyle.gviBufferCapround); _rPolygon.SetFdeGeometry(this._geo); if (this._onFinishedDraw != null) { this._onFinishedDraw(); } } } else if (e.eventSender == gviMouseSelectMode.gviMouseSelectMove) { if (_rPoint != null) { this._objectManager.DeleteObject(_rPoint.Guid); System.Runtime.InteropServices.Marshal.ReleaseComObject(_rPoint); _rPoint = null; } _rPoint = this._objectManager.CreateRenderPoint(pt1, this._simplePointSymbol, this._rootID); if (this._isStarted) { _polyline.UpdatePoint(1, pt1); _rPolyline.SetFdeGeometry(_polyline); _label.Position = _polyline.Midpoint; _label.Text = _polyline.Length.ToString("0.00") + " 米"; double radius = Math.Sqrt((startPoint.X - pt1.X) * (startPoint.X - pt1.X) + (startPoint.Y - pt1.Y) * (startPoint.Y - pt1.Y) + (startPoint.Z - pt1.Z) * (startPoint.Z - pt1.Z)); this._geo = (startPoint as ITopologicalOperator2D).Buffer2D(radius, gviBufferStyle.gviBufferCapround); _rPolygon.SetFdeGeometry(this._geo); } } } } catch (Exception ex) { LoggingService.Error(ex.Message + "\r\n" + ex.StackTrace); } }
private void GetData() { if (this.cbLayer.SelectedItem == null) { return; } DF3DFeatureClass dffc = this.cbLayer.SelectedItem as DF3DFeatureClass; if (dffc == null) { return; } IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return; } if (_num > _count || _count == 0) { return; } ISpatialFilter filter = this._filter; filter.ResultBeginIndex = _num - 1; filter.ResultLimit = 1; IFdeCursor cursor = null; IRowBuffer row = null; try { cursor = fc.Search(filter, false); if ((row = cursor.NextRow()) != null) { #region 定位 int geoindex = row.FieldIndex("Geometry"); DF3DApplication app = DF3DApplication.Application; if (geoindex != -1 && !row.IsNull(geoindex) && app != null && app.Current3DMapControl != null) { ISurfaceSymbol ss = new SurfaceSymbolClass(); ss.Color = 0xcc00ff00; ICurveSymbol cs = new CurveSymbolClass(); cs.Color = 0xff00ff00; cs.Width = -5; ss.BoundarySymbol = cs; ISimplePointSymbol ps = new SimplePointSymbol(); ps.Size = SystemInfo.Instance.SymbolSize; ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16); IGeometry geo = row.GetValue(geoindex) as IGeometry; IPoint ptTL = null; if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline) { double x = 0; double y = 0; double z = 0; IMultiPolyline mPolyline = geo as IMultiPolyline; for (int m = 0; m < mPolyline.GeometryCount; m++) { IPolyline polyline = mPolyline.GetPolyline(m); IPoint pttemp = polyline.Midpoint; x += pttemp.X; y += pttemp.Y; z += pttemp.Z; } x = x / mPolyline.GeometryCount; y = y / mPolyline.GeometryCount; z = z / mPolyline.GeometryCount; ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); ptTL.X = x; ptTL.Y = y; ptTL.Z = z; IRenderMultiPolyline rMPolyline = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolyline(mPolyline, cs, app.Current3DMapControl.ProjectTree.RootID); rMPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything; rMPolyline.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rMPolyline.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rMPolyline.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolygon) { double x = 0; double y = 0; double z = 0; IMultiPolygon mPolygon = geo as IMultiPolygon; for (int m = 0; m < mPolygon.GeometryCount; m++) { IPolygon polygon = mPolygon.GetPolygon(m); IPoint pttemp = polygon.Centroid; x += pttemp.X; y += pttemp.Y; z += pttemp.Z; } x = x / mPolygon.GeometryCount; y = y / mPolygon.GeometryCount; z = z / mPolygon.GeometryCount; ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); ptTL.X = x; ptTL.Y = y; ptTL.Z = z; IRenderMultiPolygon rMPolygon = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolygon(mPolygon, ss, app.Current3DMapControl.ProjectTree.RootID); rMPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything; rMPolygon.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rMPolygon.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rMPolygon.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryPolyline) { IPolyline polyline = geo as IPolyline; ptTL = polyline.Midpoint; IRenderPolyline rPolyline = app.Current3DMapControl.ObjectManager.CreateRenderPolyline(polyline, cs, app.Current3DMapControl.ProjectTree.RootID); rPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything; rPolyline.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rPolyline.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rPolyline.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryPoint) { IPoint point = geo as IPoint; ptTL = point; IRenderPoint rPoint = app.Current3DMapControl.ObjectManager.CreateRenderPoint(point, ps, app.Current3DMapControl.ProjectTree.RootID); rPoint.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rPoint.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rPoint.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryPolygon) { IPolygon polygon = geo as IPolygon; ptTL = polygon.Centroid; IRenderPolygon rPolygon = app.Current3DMapControl.ObjectManager.CreateRenderPolygon(polygon, ss, app.Current3DMapControl.ProjectTree.RootID); rPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything; rPolygon.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rPolygon.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rPolygon.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryModelPoint) { ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); IModelPoint mp = geo as IModelPoint; ptTL.X = mp.X; ptTL.Y = mp.Y; ptTL.Z = mp.Z; IModelPointSymbol mps = new ModelPointSymbol(); mps.SetResourceDataSet(fc.FeatureDataSet); IRenderGeometry render = app.Current3DMapControl.ObjectManager.CreateRenderModelPoint(mp, mps, app.Current3DMapControl.ProjectTree.RootID); render.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(render.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(render.Guid, gviActionCode.gviActionJump); } if (ptTL != null) { ITableLabel tl = DrawTool.CreateTableLabel1(1); tl.TitleText = "属性查询"; tl.SetRecord(0, 0, dffc.ToString()); if (ptTL != null) { tl.Position = ptTL; } app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo); app.Current3DMapControl.ObjectManager.DelayDelete(tl.Guid, 8000); } } #endregion FacilityClass facc = dffc.GetFacilityClass(); if (facc == null) { IFieldInfoCollection fiCol = fc.GetFields(); for (int i = 0; i < fiCol.Count; i++) { IFieldInfo fi = fiCol.Get(i); object obj = row.GetValue(i); string str = ""; switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldUnknown: case gviFieldType.gviFieldGeometry: continue; case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldDouble: double d; if (double.TryParse(obj.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj.ToString(); break; } DataRow dr = this._dtShow.NewRow(); dr["Property"] = string.IsNullOrEmpty(fi.Alias) ? fi.Name : fi.Alias; dr["Value"] = str; this._dtShow.Rows.Add(dr); } } else { List <DFDataConfig.Class.FieldInfo> facFields = facc.FieldInfoCollection; if (facFields != null) { foreach (DFDataConfig.Class.FieldInfo facField in facFields) { if (!facField.CanQuery) { continue; } int index = row.FieldIndex(facField.Name); if (index != -1 && !row.IsNull(index)) { object obj = row.GetValue(index); string str = ""; IFieldInfo fiFC = row.Fields.Get(index); switch (fiFC.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldUnknown: case gviFieldType.gviFieldGeometry: continue; case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldDouble: double d; if (double.TryParse(obj.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj.ToString(); break; } DataRow dr = this._dtShow.NewRow(); dr["Property"] = facField.ToString(); dr["Value"] = str; this._dtShow.Rows.Add(dr); } } } } } } 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; } } }
private void DrawBox() { try { IPolyline line = this._drawTool.GetGeo() as IPolyline; if (line == null || line.PointCount != 2) { return; } DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } if (this._renderBox != null) { app.Current3DMapControl.ObjectManager.DeleteObject(this._renderBox.Guid); this._renderBox = null; } if (this._renderPolygon != null) { app.Current3DMapControl.ObjectManager.DeleteObject(this._renderPolygon.Guid); this._renderPolygon = null; } double middleZ = (line.StartPoint.Z + line.EndPoint.Z) / 2; double minZ = middleZ + (double)this.seMinHeight.Value; double maxZ = middleZ + (double)this.seMaxHeight.Value; IPoint startPoint = line.StartPoint; IPoint endPoint = line.EndPoint; IEulerAngle ang = app.Current3DMapControl.Camera.GetAimingAngles2(startPoint, endPoint); IEulerAngle angcz = new EulerAngle(); angcz.Set(ang.Heading - 90, ang.Tilt, ang.Roll); IPoint pt1 = app.Current3DMapControl.Camera.GetAimingPoint2(startPoint, angcz, this.tbcClipDis.Value); IPoint pt2 = app.Current3DMapControl.Camera.GetAimingPoint2(endPoint, angcz, this.tbcClipDis.Value); ICRSFactory crsFact = new CRSFactory(); ISpatialCRS crs = crsFact.CreateFromWKT(app.Current3DMapControl.GetCurrentCrsWKT()) as ISpatialCRS; IGeometryFactory geoFact = new GeometryFactoryClass(); IPoint pointb1 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointb1.SpatialCRS = crs; pointb1.SetCoords(startPoint.X, startPoint.Y, minZ, 0, 0); IPoint pointb2 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointb2.SpatialCRS = crs; pointb2.SetCoords(endPoint.X, endPoint.Y, minZ, 0, 0); IPoint pointb3 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointb3.SpatialCRS = crs; pointb3.SetCoords(pt2.X, pt2.Y, minZ, 0, 0); IPoint pointb4 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointb1.SpatialCRS = crs; pointb4.SetCoords(pt1.X, pt1.Y, minZ, 0, 0); IPolygon polygonBottom = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygonBottom.SpatialCRS = crs; polygonBottom.ExteriorRing.AppendPoint(pointb1); polygonBottom.ExteriorRing.AppendPoint(pointb2); polygonBottom.ExteriorRing.AppendPoint(pointb3); polygonBottom.ExteriorRing.AppendPoint(pointb4); IPoint pointt1 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointt1.SpatialCRS = crs; pointt1.SetCoords(startPoint.X, startPoint.Y, maxZ, 0, 0); IPoint pointt2 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointt2.SpatialCRS = crs; pointt2.SetCoords(endPoint.X, endPoint.Y, maxZ, 0, 0); IPoint pointt3 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointt3.SpatialCRS = crs; pointt3.SetCoords(pt2.X, pt2.Y, maxZ, 0, 0); IPoint pointt4 = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pointt4.SpatialCRS = crs; pointt4.SetCoords(pt1.X, pt1.Y, maxZ, 0, 0); IPolygon polygonTop = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygonTop.SpatialCRS = crs; polygonTop.ExteriorRing.AppendPoint(pointt1); polygonTop.ExteriorRing.AppendPoint(pointt2); polygonTop.ExteriorRing.AppendPoint(pointt3); polygonTop.ExteriorRing.AppendPoint(pointt4); IPolygon polygon1 = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygon1.SpatialCRS = crs; polygon1.ExteriorRing.AppendPoint(pointb1); polygon1.ExteriorRing.AppendPoint(pointb2); polygon1.ExteriorRing.AppendPoint(pointt2); polygon1.ExteriorRing.AppendPoint(pointt1); IPolygon polygon2 = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygon2.SpatialCRS = crs; polygon2.ExteriorRing.AppendPoint(pointb1); polygon2.ExteriorRing.AppendPoint(pointb4); polygon2.ExteriorRing.AppendPoint(pointt4); polygon2.ExteriorRing.AppendPoint(pointt1); IPolygon polygon3 = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygon3.SpatialCRS = crs; polygon3.ExteriorRing.AppendPoint(pointb2); polygon3.ExteriorRing.AppendPoint(pointb3); polygon3.ExteriorRing.AppendPoint(pointt3); polygon3.ExteriorRing.AppendPoint(pointt2); IPolygon polygon4 = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygon4.SpatialCRS = crs; polygon4.ExteriorRing.AppendPoint(pointb3); polygon4.ExteriorRing.AppendPoint(pointb4); polygon4.ExteriorRing.AppendPoint(pointt4); polygon4.ExteriorRing.AppendPoint(pointt3); IMultiPolygon multiPolygon = geoFact.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon; multiPolygon.SpatialCRS = crs; multiPolygon.AddPolygon(polygonBottom); multiPolygon.AddPolygon(polygonTop); //multiPolygon.AddPolygon(polygon1); multiPolygon.AddPolygon(polygon2); multiPolygon.AddPolygon(polygon3); multiPolygon.AddPolygon(polygon4); ISurfaceSymbol ss = new SurfaceSymbolClass(); ss.Color = 0x550000AA; ICurveSymbol cs = new CurveSymbolClass(); cs.Color = 0xff0000AA; ss.BoundarySymbol = cs; this._renderPolygon = app.Current3DMapControl.ObjectManager.CreateRenderPolygon(polygon1, ss, app.Current3DMapControl.ProjectTree.RootID); ISurfaceSymbol ss1 = new SurfaceSymbolClass(); ss1.Color = 0x88FFFFFF; ICurveSymbol cs1 = new CurveSymbolClass(); cs1.Color = 0xffffffff; ss1.BoundarySymbol = cs1; this._renderBox = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolygon(multiPolygon, ss1, app.Current3DMapControl.ProjectTree.RootID); _env = null; _ang = null; _center = null; _env = new EnvelopeClass(); double xdis = Math.Sqrt((pointb1.X - pointb2.X) * (pointb1.X - pointb2.X) + (pointb1.Y - pointb2.Y) * (pointb1.Y - pointb2.Y)) / 2; double ydis = Math.Sqrt((pointb1.X - pointb4.X) * (pointb1.X - pointb4.X) + (pointb1.Y - pointb4.Y) * (pointb1.Y - pointb4.Y)) / 2; _env.MinZ = -ydis; _env.MaxZ = ydis; _env.MinX = -xdis; _env.MaxX = xdis; _env.MinY = -(maxZ - minZ) / 2.0; _env.MaxY = (maxZ - minZ) / 2.0; _center = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); _center.SpatialCRS = crs; _center.X = polygonBottom.Centroid.X; _center.Y = polygonBottom.Centroid.Y; _center.Z = polygon1.Centroid.Z; _ang = new EulerAngleClass(); _ang.Set(angcz.Heading, 0, 0); } catch (Exception ex) { } }
private void DrawControlRegion() { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null || !app.Current3DMapControl.Terrain.IsRegistered) { return; } if (this._renderBox != null) { app.Current3DMapControl.ObjectManager.DeleteObject(this._renderBox.Guid); this._renderBox = null; } IGeometry geo = this._drawTool.GetGeo(); if (geo == null || geo.GeometryType != gviGeometryType.gviGeometryPolygon) { return; } IPolygon polygon = geo as IPolygon; double terrainHeight = 0.0; if (app.Current3DMapControl.Terrain.IsRegistered) { terrainHeight = app.Current3DMapControl.Terrain.GetElevation(polygon.Centroid.X, polygon.Centroid.Y, gviGetElevationType.gviGetElevationFromDatabase); } double height = double.Parse(this.seLimitHeight.Value.ToString()) + terrainHeight; IGeometryFactory geoFact = new GeometryFactoryClass(); IMultiPolygon multiPolygon = geoFact.CreateGeometry(gviGeometryType.gviGeometryMultiPolygon, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolygon; IPolygon polygonZ = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; for (int i = 0; i < polygon.ExteriorRing.PointCount; i++) { IPoint ptTemp = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); IPoint pt1 = polygon.ExteriorRing.GetPoint(i); ptTemp.X = pt1.X; ptTemp.Y = pt1.Y; ptTemp.Z = height; polygonZ.ExteriorRing.AppendPoint(ptTemp); } multiPolygon.AddPolygon(polygonZ); for (int i = 0; i < polygon.ExteriorRing.PointCount - 1; i++) { IPoint pt0 = polygon.ExteriorRing.GetPoint(i); IPoint pt1 = polygon.ExteriorRing.GetPoint(i + 1); IPoint pt00 = polygonZ.ExteriorRing.GetPoint(i); IPoint pt11 = polygonZ.ExteriorRing.GetPoint(i + 1); IPolygon polygon1 = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygon1.ExteriorRing.AppendPoint(pt0); polygon1.ExteriorRing.AppendPoint(pt1); polygon1.ExteriorRing.AppendPoint(pt11); polygon1.ExteriorRing.AppendPoint(pt00); multiPolygon.AddPolygon(polygon1); } IPoint ptL0 = polygon.ExteriorRing.GetPoint(0); IPoint ptL1 = polygon.ExteriorRing.GetPoint(polygon.ExteriorRing.PointCount - 1); IPoint ptL00 = polygonZ.ExteriorRing.GetPoint(0); IPoint ptL11 = polygonZ.ExteriorRing.GetPoint(polygon.ExteriorRing.PointCount - 1); IPolygon polygon2 = geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; polygon2.ExteriorRing.AppendPoint(ptL00); polygon2.ExteriorRing.AppendPoint(ptL11); polygon2.ExteriorRing.AppendPoint(ptL1); polygon2.ExteriorRing.AppendPoint(ptL0); multiPolygon.AddPolygon(polygon2); ISurfaceSymbol ss1 = new SurfaceSymbolClass(); ss1.Color = 0x88FFFFFF; ICurveSymbol cs1 = new CurveSymbolClass(); cs1.Color = 0xffffffff; ss1.BoundarySymbol = cs1; this._renderBox = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolygon(multiPolygon, ss1, app.Current3DMapControl.ProjectTree.RootID); app.Current3DMapControl.HighlightHelper.Color = 0xAAFF0000; app.Current3DMapControl.HighlightHelper.SetRegion(geo); app.Current3DMapControl.HighlightHelper.MinZ = height; app.Current3DMapControl.HighlightHelper.VisibleMask = 15; }
private IGeometrySymbol GetGeometrySymbol(string GeoType, XmlNode symbolNode) { IGeometrySymbol result = null; if (GeoType != null) { if (!(GeoType == "ModelPoint")) { if (!(GeoType == "PointCloud")) { if (!(GeoType == "SimplePoint")) { if (!(GeoType == "ImagePoint")) { if (!(GeoType == "Polyline")) { if (GeoType == "Polygon") { result = new SurfaceSymbolClass { Color = uint.Parse(symbolNode.Attributes["FillColor"].Value), EnableLight = bool.Parse(symbolNode.Attributes["EnableLight"].Value), BoundarySymbol = { Color = uint.Parse(symbolNode.Attributes["Color"].Value), Width = float.Parse(symbolNode.Attributes["Width"].Value), ImageName = symbolNode.Attributes["ImageName"].Value } }; } } else { ICurveSymbol curveSymbol = new CurveSymbolClass(); curveSymbol.Color = uint.Parse(symbolNode.Attributes["Color"].Value); curveSymbol.Width = float.Parse(symbolNode.Attributes["Width"].Value); curveSymbol.ImageName = symbolNode.Attributes["ImageName"].Value; if (symbolNode.Attributes["RepeatLength"] != null) { curveSymbol.RepeatLength = float.Parse(symbolNode.Attributes["RepeatLength"].Value); } result = curveSymbol; } } else { result = new ImagePointSymbolClass { Size = int.Parse(symbolNode.Attributes["Size"].Value), Alignment = (gviPivotAlignment)System.Enum.Parse(typeof(gviPivotAlignment), symbolNode.Attributes["Alignment"].Value), ImageName = Path.Combine(System.Windows.Forms.Application.StartupPath + @"\..\Image\" + symbolNode.Attributes["ImageName"].Value) }; } } else { result = new SimplePointSymbolClass { Size = int.Parse(symbolNode.Attributes["Size"].Value), Alignment = (gviPivotAlignment)System.Enum.Parse(typeof(gviPivotAlignment), symbolNode.Attributes["Alignment"].Value), FillColor = uint.Parse(symbolNode.Attributes["FillColor"].Value), Style = (gviSimplePointStyle)System.Enum.Parse(typeof(gviSimplePointStyle), symbolNode.Attributes["Style"].Value) }; } } else { result = new PointCloudSymbolClass { Color = uint.Parse(symbolNode.Attributes["Color"].Value), EnableColor = symbolNode.Attributes["EnableColor"].Value.ToLower() == "true", Size = int.Parse(symbolNode.Attributes["Size"].Value) }; } } else { IModelPointSymbol modelPointSymbol = new ModelPointSymbolClass(); modelPointSymbol.Color = uint.Parse(symbolNode.Attributes["Color"].Value); modelPointSymbol.EnableColor = (symbolNode.Attributes["EnableColor"].Value.ToLower() == "true"); XmlAttribute xmlAttribute = symbolNode.Attributes["EnableTexture"]; if (xmlAttribute != null) { modelPointSymbol.EnableTexture = (xmlAttribute.Value.ToLower() == "true"); } result = modelPointSymbol; } } return(result); }
private void btnAnalyse_Click(object sender, EventArgs e) { try { ClearRes(); WaitForm.Start("正在分析...", "请稍后"); if (this._rLine == null) { return; } List <DF3DFeatureClass> list = DF3DFeatureClassManager.Instance.GetAllFeatureClass(); if (list == null || list.Count == 0) { return; } IPolyline line = this._rLine.GetFdeGeometry() as IPolyline; ILine l = this._geoFactory.CreateGeometry(gviGeometryType.gviGeometryLine, gviVertexAttribute.gviVertexAttributeZ) as ILine; l.StartPoint = line.StartPoint; l.EndPoint = line.EndPoint; ISpatialFilter filter = new SpatialFilter(); filter.SpatialRel = gviSpatialRel.gviSpatialRelEnvelope; filter.GeometryField = "Geometry"; List <InterPt> listInterPts = new List <InterPt>(); foreach (DF3DFeatureClass dffc in list) { IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { continue; } IFeatureLayer fl = dffc.GetFeatureLayer(); if (fl != null) { if (fl.VisibleMask == gviViewportMask.gviViewNone) { continue; } } int indexGeo = fc.GetFields().IndexOf("Geometry"); if (indexGeo == -1) { continue; } filter.Geometry = l; IFdeCursor cursor = null; IRowBuffer row = null; try { cursor = fc.Search(filter, false); while ((row = cursor.NextRow()) != null) { if (!row.IsNull(indexGeo)) { IGeometry geo = row.GetValue(indexGeo) as IGeometry; if (geo.GeometryType == gviGeometryType.gviGeometryModelPoint) { IModelPoint modelPoint = geo as IModelPoint; IModel model = (fc.FeatureDataSet as IResourceManager).GetModel(modelPoint.ModelName); IGeometryConvertor gc = new GeometryConvertor(); IMultiTriMesh triMesh = gc.ModelPointToTriMesh(model, modelPoint, false); if (triMesh != null) { IVector3 v3 = triMesh.LineSegmentIntersect(l); if (v3 != null) { IPoint pttemp = this._geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pttemp.X = v3.X; pttemp.Y = v3.Y; pttemp.Z = v3.Z; double dis = (pttemp.X - line.StartPoint.X) * (pttemp.X - line.StartPoint.X) + (pttemp.Y - line.StartPoint.Y) * (pttemp.Y - line.StartPoint.Y) + (pttemp.Z - line.StartPoint.Z) * (pttemp.Z - line.StartPoint.Z); InterPt ip = new InterPt(); ip.pt = pttemp; ip.dis = dis; listInterPts.Add(ip); } } } } } } catch (Exception ex) { } finally { if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } } } if (listInterPts.Count > 0) { this._rLine.VisibleMask = gviViewportMask.gviViewNone; listInterPts.Sort(new CmpInterPt()); IPoint pt = listInterPts[0].pt; IPolyline lineStart = this._geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline; lineStart.AppendPoint(line.StartPoint); lineStart.AppendPoint(pt); ICurveSymbol csS = new CurveSymbolClass(); csS.Color = 0xff0000ff; csS.Width = -2; IRenderPolyline rLineStart = this._3DControl.ObjectManager.CreateRenderPolyline(lineStart, csS, this._3DControl.ProjectTree.RootID); this._listRes.Add(rLineStart.Guid); IPolyline lineEnd = this._geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline; lineEnd.AppendPoint(line.EndPoint); lineEnd.AppendPoint(pt); ICurveSymbol csE = new CurveSymbolClass(); csE.Color = 0xffff0000; csE.Width = -2; IRenderPolyline rLineEnd = this._3DControl.ObjectManager.CreateRenderPolyline(lineEnd, csE, this._3DControl.ProjectTree.RootID); this._listRes.Add(rLineEnd.Guid); } else { this._rLine.VisibleMask = gviViewportMask.gviViewNone; ICurveSymbol csS = new CurveSymbolClass(); csS.Color = 0xff0000ff; csS.Width = -2; IRenderPolyline rLine = this._3DControl.ObjectManager.CreateRenderPolyline(line, csS, this._3DControl.ProjectTree.RootID); this._listRes.Add(rLine.Guid); } } catch (Exception ex) { } finally { WaitForm.Stop(); } }