/// <summary> /// Draws the CurrentEnvironment to the screen. /// </summary> public void draw(Graphics g, CoordinateFrame frame) { float sx, sy; float gx, gy; frame.convertToDisplay((float)start_point.X, (float)start_point.Y, out sx, out sy); frame.convertToDisplay((float)goal_point.X, (float)goal_point.Y, out gx, out gy); Rectangle startrect = new Rectangle((int)sx - 3, (int)sy - 3, 6, 6); Rectangle goalrect = new Rectangle((int)gx - 3, (int)gy - 3, 6, 6); float rx, ry, rsx, rsy; frame.convertToDisplay((float)AOIRectangle.X, (float)AOIRectangle.Y, out rx, out ry); frame.convertToDisplayOffset((float)AOIRectangle.Width, (float)AOIRectangle.Height, out rsx, out rsy); Rectangle AOIDisplay = new Rectangle((int)rx, (int)ry, (int)rsx, (int)rsy); //Display Area of Interest rectangle g.DrawRectangle(EngineUtilities.DashedPen, AOIDisplay); g.DrawEllipse(EngineUtilities.BluePen, startrect); g.DrawEllipse(EngineUtilities.RedPen, goalrect); //Display Point Of Interests int index = 0; foreach (Point p in POIPosition) { Point p2 = frame.convertToDisplay(p); g.DrawEllipse(EngineUtilities.GreendPen, new Rectangle((int)p2.X - 3, (int)p2.Y - 3, 6, 6)); g.DrawString(index.ToString(), new Font("Verdana", 8), new SolidBrush(Color.Black), p2.X, p2.Y); index++; } foreach (Wall wall in walls) { wall.draw(g, frame); } if (!this.AgentVisible) { return; } List <RobotAgent> agents = this.agents.Values.ToList(); foreach (RobotAgent agent in agents) { if (!agent.Visible) { continue; } agent.draw(g, frame, agent == CurrentAgent?ShowTrail:false); } }
/// <summary> /// Draws the wall to the screen. /// </summary> public void draw(Graphics graphics, CoordinateFrame frame) { float ax, ay, bx, by; frame.convertToDisplay((float)Line.Endpoint1.X, (float)Line.Endpoint1.Y, out ax, out ay); frame.convertToDisplay((float)Line.Endpoint2.X, (float)Line.Endpoint2.Y, out bx, out by); if (Visible) { graphics.DrawLine(EngineUtilities.BluePen, ax, ay, bx, by); } else { graphics.DrawLine(EngineUtilities.GreendPen, ax, ay, bx, by); } }