Example #1
0
        private static void DessineRobot(Robot robot, Graphics g)
        {
            Point positionRobot = RealToScreenPosition(robot.Position.Coordonnees);

            Bitmap bmpRobot = new Bitmap(Properties.Resources.Capot.Width, Properties.Resources.Capot.Height);
            Graphics gGros = Graphics.FromImage(bmpRobot);
            /*gGros.FillRectangle(brushTransparent, 0, 0, RealToScreenDistance(robot.Taille * 2), RealToScreenDistance(robot.Taille * 2));

            gGros.FillRectangle(brushBlanc, bmpRobot.Width / 2 - RealToScreenDistance(robot.Largeur / 2), bmpRobot.Height / 2 - RealToScreenDistance(robot.Longueur / 2), RealToScreenDistance(robot.Largeur), RealToScreenDistance(robot.Longueur));
            gGros.DrawRectangle(Plateau.NotreCouleur == Plateau.CouleurGaucheJaune ? penCouleurJ1R : penCouleurJ2J, bmpRobot.Width / 2 - RealToScreenDistance(robot.Largeur / 2), bmpRobot.Height / 2 - RealToScreenDistance(robot.Longueur / 2), RealToScreenDistance(robot.Largeur), RealToScreenDistance(robot.Longueur));
            gGros.DrawLine(Plateau.NotreCouleur == Plateau.CouleurGaucheJaune ? penCouleurJ1R : penCouleurJ2J, bmpRobot.Width / 2, bmpRobot.Height / 2, bmpRobot.Width / 2, bmpRobot.Height / 2 - RealToScreenDistance(robot.Longueur / 2));
            */

            gGros.DrawImage(Properties.Resources.Capot, 0, 0, Properties.Resources.Capot.Width, Properties.Resources.Capot.Height);

            // Dessiner les actionneurs ici
            if (robot == Robots.GrosRobot)
            {

            }

            g.DrawImage(RotateImage(bmpRobot, robot.Position.Angle.AngleDegres + 90), positionRobot.X - bmpRobot.Width / 2, positionRobot.Y - bmpRobot.Height / 2);
        }
Example #2
0
        private static void DessineGraph(Robot robot, Graphics g)
        {
            // Dessin du graph
            //robot.SemGraph.WaitOne();
            Pen pen = robot == Robots.GrosRobot ? penBleuFin : penBleuClairFin;
            Brush brush = robot == Robots.GrosRobot ? brushBleu : brushBleuClair;

            Synchronizer.Lock(robot.Graph);

            // Dessin des arcs
            if ((robot == Robots.GrosRobot ? AfficheGraphArretesGros : AfficheGraphArretesPetit))
                foreach (Arc a in robot.Graph.Arcs)
                {
                    if (a.Passable != false)
                    {
                        g.DrawLine(pen, RealToScreenPosition(a.StartNode.X, a.StartNode.Y), RealToScreenPosition(a.EndNode.X, a.EndNode.Y));
                    }
                }

            if ((robot == Robots.GrosRobot ? AfficheGraphGros : AfficheGraphPetit))
                // Dessin des noeuds
                foreach (Node n in robot.Graph.Nodes)
                {
                    Point pointNode = RealToScreenPosition(new PointReel(n.Position.X, n.Position.Y));
                    g.FillEllipse(brush, new Rectangle(pointNode.X - 3, pointNode.Y - 3, 6, 6));
                    g.DrawEllipse(n.Passable ? penNoir : penRougeFin, new Rectangle(pointNode.X - 3, pointNode.Y - 3, 6, 6));
                }

            Synchronizer.Unlock(robot.Graph);

            //robot.SemGraph.Release();
        }
Example #3
0
 private static void DessineHistoriqueTrajectoire(Robot robot, Graphics g)
 {
     for (int i = 1; i < Robots.GrosRobot.HistoriqueCoordonnees.Count; i++)
     {
         int couleur = (int)(i * 1200 / robot.HistoriqueCoordonnees.Count * 255 / 1200);
         PointReel point = RealToScreenPosition(robot.HistoriqueCoordonnees[i].Coordonnees);
         PointReel pointPrec = RealToScreenPosition(robot.HistoriqueCoordonnees[i - 1].Coordonnees);
         using (Pen p = new Pen(Color.FromArgb(couleur, couleur, couleur)))
         {
             g.DrawLine(p, (int)point.X, (int)point.Y, (int)pointPrec.X, (int)pointPrec.Y);
         }
         using (Brush b = new SolidBrush(Color.FromArgb(couleur, couleur, couleur)))
         {
             g.FillEllipse(b, (int)point.X - 3, (int)point.Y - 3, 6, 6);
             g.DrawEllipse(penNoir, (int)point.X - 3, (int)point.Y - 3, 6, 6);
         }
     }
 }
Example #4
0
        private static void DessineCoutMouvements(Robot robot, Graphics g)
        {
            Font police = new Font("Calibri", 8);
            List<Mouvements.Mouvement> mouvements = robot == Robots.GrosRobot ? Plateau.Enchainement.ListeMouvementsGros : Plateau.Enchainement.ListeMouvementsPetit;

            foreach (Mouvement m in mouvements)
            {
                Point point;
                Point pointElement = RealToScreenPosition(m.Element.Position);

                if (m.Cout != double.MaxValue && !double.IsInfinity(m.Cout))
                {
                    Point pointProche = RealToScreenPosition(m.PositionProche.Coordonnees);

                    foreach (Position p in m.Positions)
                    {
                        point = RealToScreenPosition(p.Coordonnees);
                        if (point != pointProche)
                        {
                            g.FillEllipse(brushRouge, point.X - 2, point.Y - 2, 4, 4);
                            g.DrawLine(penRougePointille, point, pointElement);
                        }
                    }

                    g.FillEllipse(brushBlanc, pointProche.X - 2, pointProche.Y - 2, 4, 4);
                    g.DrawLine(penBlanc, pointProche, pointElement);
                    g.DrawString(Math.Round(m.Cout) + "", police, brushBlanc, pointProche);
                }
                else
                {
                    if (!m.BonneCouleur())
                    {
                        foreach (Position p in m.Positions)
                        {
                            point = RealToScreenPosition(p.Coordonnees);
                            g.FillEllipse(brushBlancTransparent, point.X - 2, point.Y - 2, 4, 4);
                            g.DrawLine(penBlancTransparent, point, pointElement);
                        }
                    }
                    else
                    {
                        foreach (Position p in m.Positions)
                        {
                            point = RealToScreenPosition(p.Coordonnees);
                            g.FillEllipse(brushNoir, point.X - 2, point.Y - 2, 4, 4);
                            g.DrawLine(penNoirPointille, point, pointElement);
                        }
                    }
                }
            }
        }