void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { //获取水源点 waterPoint = IntersectPoint; //设置参数 this.numWaterHStart.Value = (decimal)IntersectPoint.Z; this.numWaterHEnd.Value = (decimal)(IntersectPoint.Z + 30); //获取缓冲区bufPolygon\renderBufPolygon radius = (double)numBufferRadius.Value; ITopologicalOperator2D to = waterPoint as ITopologicalOperator2D; bufPolygon = to.Buffer2D(radius, gviBufferStyle.gviBufferCapround) as IPolygon; ISurfaceSymbol sf = new SurfaceSymbol(); sf.Color = System.Drawing.Color.Yellow; ICurveSymbol cs = new CurveSymbol(); cs.Color = System.Drawing.Color.Yellow; sf.BoundarySymbol = cs; renderBufPolygon = this.axRenderControl1.ObjectManager.CreateRenderPolygon(bufPolygon, sf, rootId); renderBufPolygon.HeightStyle = gviHeightStyle.gviHeightOnTerrain; this.axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal; this.axRenderControl1.RcMouseClickSelect -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect); this.btnOnProcess.Enabled = true; this.btnSimulate.Enabled = true; }
private void btnSymmetricDifference_Click(object sender, EventArgs e) { ITopologicalOperator2D topoOpera = geo1 as ITopologicalOperator2D; if (topoOpera == null) { return; } IGeometry geo = topoOpera.SymmetricDifference2D(geo2); draw(geo); }
private void btnUnion_Click(object sender, EventArgs e) { ITopologicalOperator2D topoOpera = geo1 as ITopologicalOperator2D; if (topoOpera == null) { return; } IGeometry geo = topoOpera.Union2D(geo2); draw(geo); }
/// <summary> /// 获取缓冲多边形 /// </summary> /// <param name="distance">缓冲半径</param> /// <returns>缓冲多边形</returns> private IPolygon GetBufferPolygon(double distance) { IPoint startPoint = _StartRenderPoint.GetFdeGeometry() as IPoint; if (startPoint == null) { return(null); } IPoint drawSource = startPoint.Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPoint; ITopologicalOperator2D drawTopo = drawSource as ITopologicalOperator2D; IPolygon bufferPolygon = drawTopo.Buffer2D(distance, gviBufferStyle.gviBufferCapround) as IPolygon; return(bufferPolygon); }
private void btnSymmetricDifference_Click(object sender, EventArgs e) { IGeometry p = polygonList[0]; for (int i = 0; i < polygonList.Count - 1; i++) { IPolygon piplus = polygonList[i + 1]; ITopologicalOperator2D topoOpera = p as ITopologicalOperator2D; if (topoOpera == null) { continue; } p = topoOpera.SymmetricDifference2D(piplus); } if (p.GeometryType == gviGeometryType.gviGeometryMultiPolygon) { _multiPolygon = p as IMultiPolygon; } else if (p.GeometryType == gviGeometryType.gviGeometryPolygon) { _multiPolygon.AddGeometry(p); } }
/// <summary> /// 获取缓冲多边形 /// </summary> /// <param name="distance">缓冲半径</param> /// <returns>缓冲多边形</returns> private IPolygon GetBufferPolygon(double distance) { IPolyline startLine = renderPolyline.GetFdeGeometry() as IPolyline; if (startLine == null) { return(null); } IPolyline drawSource = startLine.Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPolyline; //如果是球面需投影到平面再做缓冲区计算 if (currentCRS.CrsType == gviCoordinateReferenceSystemType.gviCrsGeographic) { drawSource.Project(projectCRS); } ITopologicalOperator2D drawBufferLine = drawSource as ITopologicalOperator2D; IPolygon bufferPolygon = drawBufferLine.Buffer2D(distance, gviBufferStyle.gviBufferCapbutt) as IPolygon; bufferPolygon.SpatialCRS = drawSource.SpatialCRS; if (currentCRS.CrsType == gviCoordinateReferenceSystemType.gviCrsGeographic) { bufferPolygon.Project(currentCRS); } polygon = bufferPolygon; IPolygon ppolygon = bufferPolygon.Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPolygon; //设置三维坐标 //不被地面遮挡 for (int j = 0; j < ppolygon.ExteriorRing.PointCount; j++) { IPoint p = ppolygon.ExteriorRing.GetPoint(j); p.Z = 1; ppolygon.ExteriorRing.UpdatePoint(j, p); } return(ppolygon); }
public void StopEdit(bool bSave) { if (this._app == null || this._app.Current3DMapControl == null) { return; } try { if (this._isSpatialQuery) { if (!bSave) { this._geoEditor.CancelEdit(); } else { this._geoEditor.FinishEdit(); } if (this.spatialQueryEditStopEvent != null) { this.spatialQueryEditStopEvent(bSave); } this._isSpatialQuery = false; this._app.Current3DMapControl.InteractMode = this._InteractaMode; } else { if (this._FeatureClass != null && this._row != null) { if (!bSave) { this._geoEditor.CancelEdit(); if (this._renderGeometry != null) { this._app.Current3DMapControl.ObjectManager.DeleteObject(this._renderGeometry.Guid); System.Runtime.InteropServices.Marshal.ReleaseComObject(this._renderGeometry); this._renderGeometry = null; } this._app.Current3DMapControl.InteractMode = this._InteractaMode; } else { if (this._geoEditor.IsEditing && bSave) { this._geoEditor.FinishEdit(); } Gvitech.CityMaker.FdeCore.IFeatureClass featureClass = this._FeatureClass.GetFeatureClass(); int position = this._row.FieldIndex(this._FeatureClass.GetFeatureLayer().GeometryFieldName); IGeometry geometry = this._row.GetValue(position) as IGeometry; if (this._geoEditType == gviGeoEditType.gviGeoEditCreator) { ITopologicalOperator2D topologicalOperator2D = geometry as ITopologicalOperator2D; if (topologicalOperator2D == null || !topologicalOperator2D.IsSimple2D()) { XtraMessageBox.Show("创建的对象无效!"); this._app.Current3DMapControl.ObjectManager.DeleteObject(this._renderGeometry.Guid); System.Runtime.InteropServices.Marshal.ReleaseComObject(this._renderGeometry); this._renderGeometry = null; } else { CommandManagerServices.Instance().StartCommand(); FDECommand fDECommand = new FDECommand(true, true); SelectCollection.Instance().Clear(); IRowBufferCollection rowBufferCollection = new RowBufferCollectionClass(); rowBufferCollection.Add(this._row); CommonUtils.Instance().FdeUndoRedoManager.InsertFeatures(featureClass, rowBufferCollection); CommonUtils.Instance().Insert(this._FeatureClass, rowBufferCollection, true, true); this._app.Current3DMapControl.FeatureManager.CreateFeature(featureClass, this._row); this._app.Current3DMapControl.ObjectManager.DeleteObject(this._renderGeometry.Guid); fDECommand.SetSelectionMap(); CommandManagerServices.Instance().CallCommand(fDECommand); this._app.Workbench.UpdateMenu(); System.Runtime.InteropServices.Marshal.ReleaseComObject(this._renderGeometry); this._renderGeometry = null; } } else { CommandManagerServices.Instance().StartCommand(); FDECommand cmd = new FDECommand(false, true); CommonUtils.Instance().FdeUndoRedoManager.UpdateFeature(featureClass, this._row); CommandManagerServices.Instance().CallCommand(cmd); this._app.Workbench.UpdateMenu(); } if (this._row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(this._row); this._row = null; } this._app.Current3DMapControl.InteractMode = this._InteractaMode; } } } } catch (System.Runtime.InteropServices.COMException ex) { XtraMessageBox.Show(ex.Message); } catch (System.UnauthorizedAccessException) { XtraMessageBox.Show("拒绝访问"); } catch (System.Exception ex2) { XtraMessageBox.Show(ex2.Message); } }