using System; using System.Drawing; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; using GeoScene.Globe; namespace Cyberpipe { public partial class FrmFloodAnalysis : Office2007Form { public GSOGeoPolygon3D m_polygon3D; public GSOGlobe m_globe; private GSOPoint3d m_pntMaxAlt; private GSOPoint3d m_pntMinAlt; private double m_dTotalArea; private double m_dFloodArea; private double m_dBaseAlt; private GSOFeature m_WaterFeature; public FrmFloodAnalysis(GSOGlobe globe,GSOGeoPolygon3D polygon) { InitializeComponent(); m_globe = globe; m_polygon3D = polygon; } private void FloodSubmergeAnalysisDlg_Load(object sender, EventArgs e) { } private void buttonPlay_Click(object sender, EventArgs e) { if (m_WaterFeature != null) { m_dBaseAlt = Convert.ToDouble(textBoxWaterAlt.Text); if (m_dBaseAlt > m_pntMaxAlt.Z) { m_dBaseAlt = m_pntMaxAlt.Z; } if (m_dBaseAlt < m_pntMinAlt.Z) { m_dBaseAlt = m_pntMinAlt.Z; } textBoxWaterAlt.Text = m_dBaseAlt.ToString("f2"); trackBarAlt.Value = Math.Min((int)m_dBaseAlt, trackBarAlt.Maximum); GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; geoWater.SetAltitude(m_dBaseAlt); int nF = Convert.ToInt32(textBoxFrequency.Text); if (nF <= 0) { nF = 1; } timerPlay.Interval = (int)(1000.0 / nF); timerPlay.Start(); } else { MessageBox.Show("请先进行分析!"); } } private void buttonAnalyse_Click(object sender, EventArgs e) { timerPlay.Stop(); Analysis(); SetText(); ShowWater(); buttonSetPlayParam_Click(sender, e);//设置推荐参数 } private void Analysis() { if (m_globe != null && m_polygon3D != null) { m_dBaseAlt = Convert.ToDouble(textBoxWaterAlt.Text); m_globe.Analysis3D.NoSourceFloodAnalyse(m_polygon3D, m_dBaseAlt,out m_dFloodArea, out m_dTotalArea, out m_pntMaxAlt, out m_pntMinAlt, false,0); } } private void SetText() { textBoxPntMax.Text = m_pntMaxAlt.X.ToString("f6") + "," + m_pntMaxAlt.Y.ToString("f6") + "," + m_pntMaxAlt.Z.ToString("f2"); textBoxPntMin.Text = m_pntMinAlt.X.ToString("f6") + "," + m_pntMinAlt.Y.ToString("f6") + "," + m_pntMinAlt.Z.ToString("f2"); textBoxFloodArea.Text = m_dFloodArea.ToString("f2") + " 平方米"; textBoxTotalArea.Text = m_dTotalArea.ToString("f2") + " 平方米"; } private void ShowWater() { if (m_WaterFeature==null || m_WaterFeature.IsDeleted) { m_dBaseAlt = m_pntMinAlt.Z; GSOGeoWater geoWater = m_polygon3D.ConvertToGeoWater(); GSOExtrudeStyle extrudeStyle = new GSOExtrudeStyle(); if (checkBoxExtrude.Checked) { extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; } else { extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeNone; } extrudeStyle.ExtrudeValue = m_pntMinAlt.Z; extrudeStyle.TailPartVisible = false; GSOSimplePolygonStyle3D polygonStyle = new GSOSimplePolygonStyle3D(); polygonStyle.FillColor = Color.FromArgb(200, 0, 0, 255); extrudeStyle.BodyStyle = polygonStyle; geoWater.ExtrudeStyle = extrudeStyle; geoWater.AltitudeMode = EnumAltitudeMode.Absolute; geoWater.SetAltitude(m_dBaseAlt); geoWater.ReflectSky = false; geoWater.WaveWidth = 0.1; geoWater.Play(); m_WaterFeature = new GSOFeature(); m_WaterFeature.Geometry = geoWater; m_globe.MemoryLayer.AddFeature(m_WaterFeature); m_globe.Refresh(); trackBarAlt.Maximum = (int)m_pntMaxAlt.Z; trackBarAlt.Minimum = (int)m_pntMinAlt.Z; trackBarAlt.Value = trackBarAlt.Minimum; textBoxWaterAlt.Text = m_dBaseAlt.ToString("f2"); } else { GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; geoWater.SetAltitude(m_dBaseAlt); m_globe.Refresh(); trackBarAlt.Maximum = (int)m_pntMaxAlt.Z; trackBarAlt.Minimum = (int)m_pntMinAlt.Z; } } private void timerPlay_Tick(object sender, EventArgs e) { if (m_WaterFeature != null) { if (m_dBaseAlt > m_pntMaxAlt.Z) { if (checkBoxLoopPlay.Checked) { m_dBaseAlt = m_pntMinAlt.Z; } else { timerPlay.Stop(); } } m_dBaseAlt += (double)numericUpDownAddPerTime.Value; m_globe.Analysis3D.FetchNoSourceFloodAnalyseResult(m_dBaseAlt, out m_dFloodArea, out m_dTotalArea, out m_pntMaxAlt, out m_pntMinAlt); SetText(); textBoxWaterAlt.Text = m_dBaseAlt.ToString("f2"); trackBarAlt.Value = Math.Min((int)m_dBaseAlt, trackBarAlt.Maximum); GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; geoWater.SetAltitude(m_dBaseAlt); } } private void trackBarAlt_Scroll(object sender, EventArgs e) { textBoxWaterAlt.Text=trackBarAlt.Value.ToString(); } private void numericUpDownAddPerTime_ValueChanged(object sender, EventArgs e) { trackBarAlt.TickFrequency = Convert.ToInt32(numericUpDownAddPerTime.Value); } private void buttonStop_Click(object sender, EventArgs e) { timerPlay.Stop(); } private void checkBoxExtrude_CheckedChanged(object sender, EventArgs e) { if (m_WaterFeature != null) { GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; if (checkBoxExtrude.Checked) { geoWater.ExtrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; } else { geoWater.ExtrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeNone; } } } private void buttonSetPlayParam_Click(object sender, EventArgs e) { int nF = Convert.ToInt32(textBoxFrequency.Text); if (nF <= 0) { nF = 1; } numericUpDownAddPerTime.Maximum = (decimal)m_pntMaxAlt.Z; numericUpDownAddPerTime.Minimum = 0; double dAltDiff = (m_pntMaxAlt.Z - m_pntMinAlt.Z); numericUpDownAddPerTime.Increment = (decimal)(0.1*dAltDiff / nF); // 用10秒播放完 numericUpDownAddPerTime.Value = numericUpDownAddPerTime.Increment; trackBarAlt.Maximum = (int)m_pntMaxAlt.Z; trackBarAlt.Minimum = (int)m_pntMinAlt.Z; trackBarAlt.Value = trackBarAlt.Minimum; int nTF = (int)numericUpDownAddPerTime.Increment; if (nTF < 1) { nTF = 1; } trackBarAlt.TickFrequency = nTF; m_dBaseAlt = m_pntMinAlt.Z; textBoxWaterAlt.Text = m_dBaseAlt.ToString("f2"); } private void buttonReplay_Click(object sender, EventArgs e) { if (m_WaterFeature != null) { m_dBaseAlt = m_pntMinAlt.Z; textBoxWaterAlt.Text = m_dBaseAlt.ToString("f2"); trackBarAlt.Value = trackBarAlt.Minimum; GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; geoWater.SetAltitude(m_dBaseAlt); int nF = Convert.ToInt32(textBoxFrequency.Text); if (nF <= 0) { nF = 1; } timerPlay.Interval = (int)(1000.0 / nF); timerPlay.Start(); } else { MessageBox.Show("请先进行分析!"); } } private void FrmFloodAnalysis_FormClosing(object sender, FormClosingEventArgs e) { m_globe.ClearLastTrackPolygon(); if (m_WaterFeature != null) { m_WaterFeature.Delete(); } } } }