public void draw(Graphics g, CoordinateFrame frame)
        {
            float sx, sy;
            float gx, gy;

            frame.to_display((float)start_point.x, (float)start_point.y, out sx, out sy);
            frame.to_display((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.to_display((float)AOIRectangle.X, (float)AOIRectangle.Y, out rx, out ry);
            frame.offset_to_display((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.to_display(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);
            }
        }
        public void draw(Graphics g, CoordinateFrame frame)
        {
            float sx,sy;
            float gx,gy;

            frame.to_display((float)start_point.x,(float)start_point.y,out sx, out sy);
            frame.to_display((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.to_display((float)AOIRectangle.X,(float)AOIRectangle.Y,out rx,out ry);
            frame.offset_to_display((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.to_display(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);
            }

            foreach (Prey prey in preys)
            {
                prey.draw(g, frame);
            }
        }
Exemple #3
0
        public override void draw(Graphics g, CoordinateFrame frame)
        {
            Rectangle r = new Rectangle();
            float     cx, cy;

            frame.to_display((float)circle.p.x, (float)circle.p.y, out cx, out cy);
            r.X      = (int)(cx - radius / frame.scale);
            r.Y      = (int)(cy - radius / frame.scale);
            r.Height = (int)((radius * 2) / frame.scale);
            r.Width  = (int)((radius * 2) / frame.scale);
            if (collide_last)
            {
                g.DrawEllipse(Pens.Red, r);
            }
            else
            {
                g.DrawEllipse(Pens.Blue, r);
            }



            float x1 = (float)(Math.Cos(heading + 0.51f) * radius);
            float y1 = (float)(Math.Sin(heading + 0.51f) * radius);
            float x2 = (float)(Math.Cos(heading - 0.51f) * radius);
            float y2 = (float)(Math.Sin(heading - 0.51f) * radius);

            float x3 = (float)(Math.Cos(heading + 0.51f + 3.14f) * radius);
            float y3 = (float)(Math.Sin(heading + 0.51f + 3.14f) * radius);
            float x4 = (float)(Math.Cos(heading - 0.51f + 3.14f) * radius);
            float y4 = (float)(Math.Sin(heading - 0.51f + 3.14f) * radius);

            float ox1, ox2, ox3, ox4;
            float oy1, oy2, oy3, oy4;

            frame.offset_to_display(x1, y1, out ox1, out oy1);
            ox1 += cx;
            oy1 += cy;

            frame.offset_to_display(x2, y2, out ox2, out oy2);
            ox2 += cx;
            oy2 += cy;

            frame.offset_to_display(x3, y3, out ox3, out oy3);
            ox3 += cx;
            oy3 += cy;

            frame.offset_to_display(x4, y4, out ox4, out oy4);
            ox4 += cx;
            oy4 += cy;


            g.DrawLine(Pens.Blue, ox1, oy1, ox2, oy2);
            g.DrawLine(Pens.Blue, ox2, oy2, ox3, oy3);
            g.DrawLine(Pens.Blue, ox1, oy1, ox4, oy4);
            g.DrawLine(Pens.Blue, ox3, oy3, ox4, oy4);
            //3.14=1.57

            //if (scene.POIPosition.Count == sim_engine.robots.Count)
            //{
            //    g.DrawLine(redpen, new PointF((float)location.x, (float)location.y),
            //        new PointF(this.scene.POIPosition[agentIndex].X, this.scene.POIPosition[agentIndex].Y));
            //}

            float dx, dy;

            dx = (float)(radius * Math.Cos(heading));
            dy = (float)(radius * Math.Sin(heading));
            float odx, ody;

            frame.offset_to_display(dx, dy, out odx, out ody);
            dx += cx;
            dy += cy;
            g.DrawLine(Pens.Blue, cx, cy, dx, dy);

            //TODO: Lable drawing code, how do we know to do this?
            //label drawing
            //if (bDrawLabel)
            //    g.DrawString(robot_count.ToString(), new Font("Tahoma", 12, FontStyle.Bold), Brushes.Black, r.X, r.Y + (float)radius);
            foreach (ISensor sensor in sensors)
            {
                sensor.draw(g, frame);
            }
        }
        public override void draw(Graphics g,CoordinateFrame frame)
        {
            Rectangle r = new Rectangle();
			float cx,cy;
			frame.to_display((float)circle.p.x,(float)circle.p.y,out cx,out cy);
			r.X = (int)(cx-radius/frame.scale);
			r.Y = (int)(cy-radius/frame.scale);
			r.Height = (int)((radius * 2) / frame.scale);
            r.Width = (int)((radius * 2) / frame.scale);
            if (collide_last)
                g.DrawEllipse(Pens.Red, r);
            else
                g.DrawEllipse(Pens.Blue, r);



            float x1 = (float)(Math.Cos(heading + 0.51f) * radius);
            float y1 = (float)(Math.Sin(heading + 0.51f) * radius);
            float x2 = (float)(Math.Cos(heading - 0.51f) * radius);
            float y2 = (float)(Math.Sin(heading - 0.51f) * radius);

            float x3 = (float)(Math.Cos(heading + 0.51f + 3.14f) * radius);
            float y3 = (float)(Math.Sin(heading + 0.51f + 3.14f) * radius);
            float x4 = (float)(Math.Cos(heading - 0.51f + 3.14f) * radius);
            float y4 = (float)(Math.Sin(heading - 0.51f + 3.14f) * radius);
			
			float ox1,ox2,ox3,ox4;
			float oy1,oy2,oy3,oy4;
			
			frame.offset_to_display(x1,y1,out ox1,out oy1);
			ox1+=cx;
			oy1+=cy;

			frame.offset_to_display(x2,y2,out ox2,out oy2);
			ox2+=cx;
			oy2+=cy;

			frame.offset_to_display(x3,y3,out ox3,out oy3);
			ox3+=cx;
			oy3+=cy;

			frame.offset_to_display(x4,y4,out ox4,out oy4);
			ox4+=cx;
			oy4+=cy;

			
            g.DrawLine(Pens.Blue, ox1, oy1, ox2, oy2);
            g.DrawLine(Pens.Blue, ox2, oy2, ox3, oy3);
            g.DrawLine(Pens.Blue, ox1, oy1, ox4, oy4);
            g.DrawLine(Pens.Blue, ox3, oy3, ox4, oy4);
            //3.14=1.57

            //if (scene.POIPosition.Count == sim_engine.robots.Count)
            //{
            //    g.DrawLine(redpen, new PointF((float)location.x, (float)location.y),
            //        new PointF(this.scene.POIPosition[agentIndex].X, this.scene.POIPosition[agentIndex].Y));
            //}

            float dx, dy;

            dx = (float)(radius * Math.Cos(heading));
            dy = (float)(radius * Math.Sin(heading));
			float odx,ody;
			frame.offset_to_display(dx,dy,out odx,out ody);
			dx+=cx;
			dy+=cy;
            g.DrawLine(Pens.Blue, cx,cy, dx,dy);

            //TODO: Lable drawing code, how do we know to do this?
            //label drawing
            //if (bDrawLabel)
            //    g.DrawString(robot_count.ToString(), new Font("Tahoma", 12, FontStyle.Bold), Brushes.Black, r.X, r.Y + (float)radius);
 			foreach(ISensor sensor in sensors)
			{
				sensor.draw(g,frame);
			}
			
        }