public void DumpSlopes(string cmd, string[] cmdsplit, int player) { int sectorpospersquare = 64; int width = aicallback.GetMapWidth() / 2; int height = aicallback.GetMapHeight() / 2; double[,] slopemap = new SlopeMap().GetSlopeMap(); double maxslope = 0; int sectoredmapwidth = width * 16 / sectorpospersquare; int sectoredmapheight = height * 16 / sectorpospersquare; bool[,] sectoredslopemap = new bool[sectoredmapwidth, sectoredmapheight]; for (int y = 0; y < height; y += 1) { string line = ""; for (int x = 0; x < width; x += 1) { maxslope = Math.Max(maxslope, slopemap[x, y]); if (slopemap[x, y] > 0.08) //if( slopemap[ x, y ] > 0.33 ) { // aicallback.DrawUnit( "ARMRAD", new Float3( x * 64, 0, y * 64 ), 0.0f, 100, aicallback.GetMyAllyTeam(), true, true); line += "*"; sectoredslopemap[x / 4, y / 4] = true; } else { line += "-"; } } logfile.WriteLine(line); } for (int y = 0; y < sectoredmapheight; y++) { string line = ""; for (int x = 0; x < sectoredmapwidth; x++) { if (sectoredslopemap[x, y]) { aicallback.DrawUnit("ARMFORT", new Float3(x * 64, 0, y * 64), 0.0f, 100, aicallback.GetMyAllyTeam(), true, true); line += "*"; } else { line += "-"; } } logfile.WriteLine(line); } aicallback.SendTextMsg("slopes dumped to logfile", 0); logfile.WriteLine("maxslope: " + maxslope); }
//开始分析 private void btn_StartAnalyst_Click(object sender, EventArgs e) { if (m_slope == null) { m_slope = CreateSlope(); } this.btn_StartAnalyst.Enabled = false; this.btn_StopAnalysis.Enabled = true; this.btn_Clear.Enabled = true; this.cb_IsShowSlopInfo.Checked = false; this.RegisterEvents(false); this.RegisterEvents(true); m_sceneControl.Action = SuperMap.UI.Action3D.CreateRectangle; }
//清除所有分析结果 private void btn_Clear_Click(object sender, EventArgs e) { this.RegisterEvents(false); if (m_slope != null) { m_slope.Clear(); m_slope = null; } m_sceneControl.Action = Action3D.Pan; m_timer.Enabled = false; this.m_sceneControl.Scene.TrackingLayer.Clear(); this.btn_StopAnalysis.Enabled = false; this.btn_StartAnalyst.Enabled = true; this.btn_Clear.Enabled = false; }
//关闭窗口事件 private void DlgSlopeMap_FormClosing(object sender, FormClosingEventArgs e) { this.RegisterEvents(false); if (m_slope != null) { m_slope.Clear(); m_slope = null; } if (m_timer != null) { m_timer.Tick -= new EventHandler(timer_tick); m_timer.Stop(); m_timer = null; } this.m_sceneControl.Scene.TrackingLayer.Clear(); m_sceneControl.Action = Action3D.Pan; }
private SlopeMap CreateSlope() { Rectangle2D rect = Rectangle2D.Empty; SlopeMap slope = new SlopeMap(m_sceneControl.Scene); slope.Opacity = m_opacity; slope.BorderVisible = m_bShowBorer; slope.DisplayStyle = m_fillMode; //设置坡度坡向调色板 ColorDictionary colorDict = new ColorDictionary(); colorDict[0] = Color.Blue; colorDict[10] = Color.Green; colorDict[30] = Color.Red; slope.ColorDictTable = colorDict; slope.MaxVisibleSlope = m_maxVisibleSlope; slope.MinVisibleSlope = m_minVisibleSlope; slope.Build(); return(slope); }
public new void Start() { topology = new SlopeMap(); base.Start(); }