private void DStarLiteForm_Paint(object sender, PaintEventArgs e)
        {
            mymap = new Grid_Map(Map_column, Map_row, 20, 20, e.Graphics);
            e.Graphics.DrawImage(Map_Background, 0, 0, 800, 800);
            //Console.WriteLine("Text:" + Option_List.Text);
            mymap.begin();
            if (Path_Done == true && Show_Path == true)
            {
               if (My_D_Star_Lite.Get_U_ID_List.Count > 0)
               {
                   float width = (float)0.30;
                   float heigh = (float)0.30;
                   foreach (int Node in My_D_Star_Lite.Get_U_ID_List)
                   {
                       //mymap.Node_Highlight(Node, Color.Blue);
                       if (Node > -1)
                       {
                           mymap.Add_Object_Ratio(Closed_Nodes, Node, width, heigh);
                       }
                   }
               }
                for (int i = 0; i < Path.Count; i++)
                {
                    //Console.WriteLine("Node in Path: " + Path[i]);
                    float width = (float)0.3;
                    float heigh = (float)0.3;
                    mymap.Add_Object_Ratio(Path_Node, (int)Path[i], width, heigh);
                }

                for (int i = 0; i < Path.Count; i++)
                {
                    mymap.Show_Path(Path, false);
                }
            }
            for (int i = 0; i < Obstacle_List.Count; i++)
            {
                mymap.Node_Highlight((int)Obstacle_List[i], Color.Black);
            }

            for (int i = 0; i < New_Obstacle_List.Count; i++)
            {
                float width = (float)0.5;
                float heigh = (float)0.5;
                mymap.Add_Object_Ratio(New_Obs, (int)New_Obstacle_List[i], width, heigh);
            }
            mymap.Add_Object(Robot, Start_Point, 20, 20);
            mymap.Add_Object(Target, Goal_Point, 20, 20);
        }
示例#2
0
        private void SimulationAlgorithm_Paint(object sender, PaintEventArgs e)
        {
            mymap = new Grid_Map(Map_column, Map_row, 20, 20, e.Graphics);
            e.Graphics.DrawImage(Map_Background, 0,0,780,780);
            mymap.begin();
            if (Show_Path == true)
            {
                //mymap.Show_Path(My_A_Star.Closed_Nodes, true);
            }
            if (Path_Done == true && Show_Path == true)
            {
                if (My_D_Star.Get_Closed_Nodes.Count > 0 && My_D_Star.Get_ReOpen_Nodes.Count == 0)//First search, so there is no reopen nodes
                {
                    float width = (float)0.30;
                    float heigh = (float)0.30;
                    foreach (int Node in My_D_Star.Get_Closed_Nodes)
                    {
                        //mymap.Node_Highlight(Node, Color.Blue);
                        mymap.Add_Object_Ratio(Closed_Nodes, Node, width, heigh);
                    }
                }

                if (My_D_Star.Get_ReOpen_Nodes.Count > 0)// afeter detecting an obstacle, update node. Only display nodes which are reopened to calculate again
                {
                    float width = (float)0.3;
                    float heigh = (float)0.3;
                    foreach (int Node in My_D_Star.Get_ReOpen_Nodes)
                    {
                        //mymap.Node_Highlight(Node, Color.Green);
                        mymap.Add_Object_Ratio(Closed_Nodes, Node, width, heigh);
                    }
                }
                for (int i = 0; i < Path.Count; i++)
                {
                    Console.WriteLine("Node in Path: " + Path[i]);
                    float width = (float)0.3;
                    float heigh = (float)0.3;
                    mymap.Add_Object_Ratio(Path_Node, (int)Path[i], width, heigh);
                }
                for (int i = 0; i < Path.Count; i++)
                {
                    mymap.Show_Path(Path, false);
                }
            }
            for (int i = 0; i < Obstacle_List.Count; i++)
            {
                mymap.Node_Highlight((int)Obstacle_List[i], Color.Black);
            }
            for (int i = 0; i < New_Obstacle_List.Count; i++)
            {
                float width = (float)0.5;
                float heigh = (float)0.5;
                mymap.Add_Object_Ratio(New_Obs, (int)New_Obstacle_List[i], width, heigh);
            }
            mymap.Add_Object(Robot, Start_Point, 25, 25);
            mymap.Add_Object(Target, Goal_Point, 35, 35);
        }