public bool CreateTerrainModifier(List <IPolygon> regions, double height, gviElevationBehaviorMode elevationMode = 0) { try { if ((regions == null) || (regions.Count <= 0)) { return(false); } if (this._terrainModifierList == null) { this._terrainModifierList = new List <ITerrainModifier>(); } this.terrainHeight = height; foreach (IPolygon polygon in regions) { ITerrainModifier item = this.CreateSingleTerrainModifier(polygon, height, elevationMode); if (item != null) { this._terrainModifierList.Add(item); } } this.gviviewportMask = gviViewportMask.gviViewAllNormalView; return(true); } catch (Exception exception) { return(false); } }
private void toolStripButtonCreateTerrainModifier_Click(object sender, System.EventArgs e) { TerrainModifierSettingForm form = new TerrainModifierSettingForm(); if (form.ShowDialog() == DialogResult.OK) { order = form.Order; switch (form.Strtype) { case "用定义了高程的多边形替代相应地形区域中大于多边形高程部分的高程值": mode = gviElevationBehaviorMode.gviElevationBehaviorAbove; break; case "用定义了高程的多边形替代相应地形区域中小于多边形高程部分的高程值": mode = gviElevationBehaviorMode.gviElevationBehaviorBelow; break; case "用定义了高程的多边形替代相应的地形区域的高程值": mode = gviElevationBehaviorMode.gviElevationBehaviorReplace; break; } currentGeometry = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZ) as IPolygon; currentGeometry.SpatialCRS = crs as ISpatialCRS; ISurfaceSymbol sfbottom = new SurfaceSymbol(); sfbottom.Color = System.Drawing.Color.Red; currentRenderGeometry = this.axRenderControl1.ObjectManager.CreateRenderPolygon(currentGeometry as IPolygon, sfbottom, rootId); (currentRenderGeometry as IRenderPolygon).HeightStyle = gviHeightStyle.gviHeightOnTerrain; this.axRenderControl1.InteractMode = gviInteractMode.gviInteractEdit; this.axRenderControl1.ObjectEditor.StartEditRenderGeometry(currentRenderGeometry, gviGeoEditType.gviGeoEditCreator); } }
private void 属性ToolStripMenuItem_Click(object sender, System.EventArgs e) { myListNode selectNode = this.listView1.SelectedItems[0] as myListNode; if (selectNode != null) { ITerrainModifier modifier = selectNode.obj as ITerrainModifier; if (modifier == null) { return; } int index = 0; switch (modifier.ElevationBehavior) { case gviElevationBehaviorMode.gviElevationBehaviorAbove: index = 2; break; case gviElevationBehaviorMode.gviElevationBehaviorBelow: index = 1; break; case gviElevationBehaviorMode.gviElevationBehaviorReplace: index = 0; break; } TerrainModifierSettingForm form = new TerrainModifierSettingForm(modifier.DrawOrder, index); if (form.ShowDialog() == DialogResult.OK) { order = form.Order; switch (form.Strtype) { case "用定义了高程的多边形替代相应地形区域中大于多边形高程部分的高程值": mode = gviElevationBehaviorMode.gviElevationBehaviorAbove; break; case "用定义了高程的多边形替代相应地形区域中小于多边形高程部分的高程值": mode = gviElevationBehaviorMode.gviElevationBehaviorBelow; break; case "用定义了高程的多边形替代相应的地形区域的高程值": mode = gviElevationBehaviorMode.gviElevationBehaviorReplace; break; } modifier.DrawOrder = order; modifier.ElevationBehavior = mode; } } }
private void 生成地形编辑ToolStripMenuItem_Click(object sender, System.EventArgs e) { myListNode selectNode = this.listView1.SelectedItems[0] as myListNode; if (selectNode != null) { IRenderPolygon rgeo = selectNode.obj as IRenderPolygon; IPolygon polygon = rgeo.GetFdeGeometry() as IPolygon; // 生成带洞polygon,可注释掉 IEnvelope env = rgeo.Envelope; IRing ring = (new GeometryFactory()).CreateGeometry(gviGeometryType.gviGeometryRing, gviVertexAttribute.gviVertexAttributeZ) as IRing; IPoint center = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); center.Position = env.Center; center.SpatialCRS = crs as ISpatialCRS; ring.AppendPoint(center); center.Y = env.Center.Y - 10; ring.AppendPoint(center); center.X = env.Center.X + 10; ring.AppendPoint(center); center.Y = env.Center.Y; ring.AppendPoint(center); polygon.AddInteriorRing(ring); // To here ISurfaceSymbol sfbottom = new SurfaceSymbol(); sfbottom.Color = System.Drawing.Color.Red; IRenderPolygon rgeoNew = this.axRenderControl1.ObjectManager.CreateRenderPolygon(polygon, sfbottom, rootId); TerrainModifierSettingForm form = new TerrainModifierSettingForm(); if (form.ShowDialog() == DialogResult.OK) { order = form.Order; switch (form.Strtype) { case "用定义了高程的多边形替代相应地形区域中大于多边形高程部分的高程值": mode = gviElevationBehaviorMode.gviElevationBehaviorAbove; break; case "用定义了高程的多边形替代相应地形区域中小于多边形高程部分的高程值": mode = gviElevationBehaviorMode.gviElevationBehaviorBelow; break; case "用定义了高程的多边形替代相应的地形区域的高程值": mode = gviElevationBehaviorMode.gviElevationBehaviorReplace; break; } ITerrainModifier modifier = this.axRenderControl1.ObjectManager.CreateTerrainModifier(polygon, rootId); if (modifier != null) { modifier.DrawOrder = order; modifier.ElevationBehavior = mode; // 添加节点到界面控件上 myListNode item = new myListNode(string.Format("TerrainModifier_{0}", modifier.Guid), TreeNodeType.NT_TerrainModifier, modifier); item.Checked = true; listView1.Items.Add(item); // 添加节点到界面控件上 item = new myListNode(string.Format("RenderPolygon_{0}", modifier.Guid), TreeNodeType.NT_RenderGeomtry, rgeoNew); item.Checked = true; listView1.Items.Add(item); } } } }
public ITerrainModifier CreateSingleTerrainModifier(IPolygon region, double height, gviElevationBehaviorMode elevationMode = 0) { try { IPolygon newVal = null; ITerrainModifier modifier = null; modifier = _3DControl.ObjectManager.CreateTerrainModifier(region, _3DControl.ProjectTree.RootID); if (modifier == null) { return(null); } IPoint pointValue = null; newVal = region.Clone() as IPolygon; for (int i = 0; i < region.ExteriorRing.PointCount; i++) { pointValue = region.ExteriorRing.GetPoint(i); pointValue.Z = height; newVal.ExteriorRing.UpdatePoint(i, pointValue); } modifier.SetPolygon(newVal); modifier.ElevationBehavior = gviElevationBehaviorMode.gviElevationBehaviorReplace; return(modifier); } catch (Exception exception) { return(null); } }