/// <summary> /// TE 右键单击事件 /// </summary> /// <param name="Flags"></param> /// <param name="X"></param> /// <param name="Y"></param> /// <param name="pbHandled"></param> void TE_OnRButtonDown(int Flags, int X, int Y, ref object pbHandled) { if (En == "DrawGeo" && !this.LockRButton) { try { ITerraExplorerObject61 pp = this.SgWorld.Creator.GetObject(this.CurrObjectID); this.mTerrainPolygon61 = pp as ITerrainPolygon61; IGeometry geo = this.mTerrainPolygon61.Geometry; IPolygon pPolygon = geo as IPolygon; ISpatialOperator _SpatialOperator = pPolygon.SpatialOperator; uint nLineColor = 0xFF00FF00; // Abgr value -> solid green uint nFillColor = 0x7FFF0000; // Abgr value -> 50% transparent blue this.geo = _SpatialOperator.buffer((double)this.spinEdit1.Value); this.SgWorld.Creator.CreatePolygon(this.geo, nLineColor, nFillColor, AltitudeTypeCode.ATC_ON_TERRAIN, GroupID, "Buffer" + System.Guid.NewGuid().ToString().Substring(0, 6)); this.LockRButton = true; //Program.TE.Save(); this.En = null; this.simpleButton2.Checked = false; } catch (Exception) { } } }
/// <summary> /// 鼠标左键按下时发生的事件(建立缓冲区的主要方法) /// </summary> /// <param name="Flags"></param> /// <param name="X"></param> /// <param name="Y"></param> /// <param name="pbHandled"></param> void TE_OnLButtonDown(int Flags, int X, int Y, ref object pbHandled) { if (En == "DrawGeo") { } else if (En == "SelectModle") { // 2012-9-20 张航宇 // 若成功的完成了一次缓冲分析,则将状态释放,要求重新点击 IWorldPointInfo61 pIWorldPointInfo = this.SgWorld.Window.PixelToWorld(X, Y, WorldPointType.WPT_MODEL); if (pIWorldPointInfo.ObjectID != "" && pIWorldPointInfo.ObjectID != null) { try { ITerraExplorerObject61 pp = this.SgWorld.Creator.GetObject(pIWorldPointInfo.ObjectID); if (pp.ObjectType == ObjectTypeCode.OT_FEATURE) { IFeature61 pIF = pp as IFeature61; this.geo = pIF.GeometryZ.SpatialOperator.buffer((double)this.spinEdit1.Value); ITerrainPolygon61 polygon = this.SgWorld.Creator.CreatePolygon(this.geo, -16711936, -10197916, cbRelative.Checked?AltitudeTypeCode.ATC_TERRAIN_RELATIVE: AltitudeTypeCode.ATC_ON_TERRAIN, GroupID, "Buffer" + System.Guid.NewGuid().ToString().Substring(0, 6)); if (cbRelative.Checked) { polygon.Position.Altitude = (double)speHeight.Value; } this.En = null; this.Select.Checked = false; } else { ITerrainModel61 pITerrainModel = this.SgWorld.Creator.GetObject(pIWorldPointInfo.ObjectID) as ITerrainModel61; IBBox3D61 pBBox = pITerrainModel.Terrain.BBox; cVerticesArray = new double[] { pBBox.MaxX, pBBox.MinY, 0, pBBox.MaxX, pBBox.MaxY, 0, pBBox.MinX, pBBox.MaxY, 0, pBBox.MinX, pBBox.MinY, 0, }; ILinearRing cRing = this.SgWorld.Creator.GeometryCreator.CreateLinearRingGeometry(cVerticesArray); IPolygon cPolygonGeometry = this.SgWorld.Creator.GeometryCreator.CreatePolygonGeometry(cRing, null); //this.geo = cPolygonGeometry as IGeometry; ISpatialOperator _SpatialOperator = cPolygonGeometry.SpatialOperator; this.geo = _SpatialOperator.buffer((double)this.spinEdit1.Value); ITerrainPolygon61 polygon = this.SgWorld.Creator.CreatePolygon(this.geo, -16711936, -10197916, cbRelative.Checked ? AltitudeTypeCode.ATC_TERRAIN_RELATIVE : AltitudeTypeCode.ATC_ON_TERRAIN, GroupID, "Buffer" + System.Guid.NewGuid().ToString().Substring(0, 6)); if (cbRelative.Checked) { polygon.Position.Altitude = (double)speHeight.Value; } this.En = null; this.Select.Checked = false; } } catch { } } } }