private void button_load_delta_Click(object sender, EventArgs e)
        {
            // Displays an OpenFileDialog so the user can select a Cursor.
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Text Files|*.txt";
            openFileDialog.Title  = "Select a Text File";

            // Show the Dialog.
            // If the user clicked OK in the dialog and
            // a .CUR file was selected, open it.
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                StreamReader sr = new StreamReader(openFileDialog.FileName);
                String       line;
                while ((line = sr.ReadLine()) != null)
                {
                    String[] posArray = line.Split();
                    ICoord   p        = initialPos.Clone();
                    p.X += Convert.ToDouble(posArray[0]);
                    p.Y += Convert.ToDouble(posArray[1]);
                    p.Z += Convert.ToDouble(posArray[2]);
                    marks.Add(p);
                    marksListBox.Items.Add(String.Format("[{0}]({0:0.00},{1:0.00},{2:0.00})", marks.Count, p.X, p.Y, p.Z));
                    outputTextBox.SelectionColor = Color.Green;
                    outputTextBox.AppendText(String.Format("Add mark [{0}]({0:0.00},{1:0.00},{2:0.00})\r\n", marks.Count, p.X, p.Y, p.Z));
                    outputTextBox.ScrollToCaret();
                }
                sr.Close();
                checkBoxZigZag.Checked = checkBoxZigZag.Enabled = false;
            }
        }
Esempio n. 2
0
 public Cell(ICoord p)
 {
     data.grid_x = p.X_coord / MapConst.MaxCells;
     data.grid_y = p.Y_coord / MapConst.MaxCells;
     data.cell_x = p.X_coord % MapConst.MaxCells;
     data.cell_y = p.Y_coord % MapConst.MaxCells;
 }
        public ICoord WhichPointIsClose(double x, double y)
        {
            ICoord obj         = lCoordonnees[0];
            double distancemin = -1;;

            double[] distancetmp    = new double[2];
            double[] distancemintmp = new double[2];
            for (int i = 0; i < lCoordonnees.Count - 1; i++)
            {
                ///Distance premier point du segment
                distancetmp[0] = MathUtil.DistanceDeuxPoints(x, y, lCoordonnees[i].X, lCoordonnees[i].Y);
                ///Distance deuxieme point du segment
                distancetmp[1] = MathUtil.DistanceDeuxPoints(x, y, lCoordonnees[i + 1].X, lCoordonnees[i + 1].Y);

                ///Distance points segment
                ///Calcul du coefficient directeut (y2 -y1)/(x2-x1)
                distancemintmp = GetDistanceMin(distancemin, distancetmp);
                if (distancemintmp[1] != -1)
                {
                    distancemin = distancemintmp[0];
                    switch (distancemintmp[1])
                    {
                    case 0:
                        obj = lCoord[i];
                        break;

                    case 1:
                        obj = lCoord[i + 1];
                        break;
                    }
                }
            }

            return(obj);
        }
Esempio n. 4
0
 private async Task MoveAsync(ICoord coord)
 {
     await _hubContext.Clients.Groups(_id).SendAsync("Move",
                                                     coord.Position.X,
                                                     coord.Position.Y,
                                                     coord.GetId());
 }
 public void relativePos(ICoord pos, ref double theta, ref double phi)
 {
     if (cnc != null)
     {
         theta = (pos.X - initialPos.X) * Metrics.degreePerUnit;
         phi   = (pos.Y - (initialPos.Y + extendY)) * Metrics.degreePerUnit;
     }
 }
Esempio n. 6
0
 public async Task EventMoving(ICoord coord)
 {
     lock (obj)
     {
         Console.SetCursorPosition(coord.Position.X, coord.Position.Y);
         Console.WriteLine(coord.GetCharElement());
     }
 }
 public void relativeTP(double theta, double phi, ref ICoord pos)
 {
     if (cnc != null)
     {
         pos.X = theta * Metrics.unitPerDegree + initialPos.X;
         pos.Y = phi * Metrics.unitPerDegree + initialPos.Y + extendY;
         pos.Z = phi * Metrics.unitPerDegree + initialPos.Z + extendZ;
     }
 }
Esempio n. 8
0
 public void DrawSnake(ICoord point)
 {
     if ((point as SnakePoint).IsTail)
     {
         Console.Write(" ");
     }
     Console.SetCursorPosition(point.X, point.Y);
     Console.Write("*");
 }
Esempio n. 9
0
        public Cell(float x, float y)
        {
            ICoord p = GridDefines.ComputeCellCoord(x, y);

            data.grid_x = p.X_coord / MapConst.MaxCells;
            data.grid_y = p.Y_coord / MapConst.MaxCells;
            data.cell_x = p.X_coord % MapConst.MaxCells;
            data.cell_y = p.Y_coord % MapConst.MaxCells;
        }
Esempio n. 10
0
 public void addMark(ICoord mark, bool quiet = false)
 {
     marks.Add(mark);
     marksListBox.Items.Add(String.Format("[{0}]({1:0.00},{2:0.00},{3:0.00})", marks.Count, mark.X, mark.Y, mark.Z));
     outputTextBox.SelectionColor = Color.Green;
     if (!quiet)
     {
         outputTextBox.AppendText(String.Format("Add mark [{0}]({1:0.00},{2:0.00},{3:0.00})\r\n", marks.Count, mark.X, mark.Y, mark.Z));
         outputTextBox.ScrollToCaret();
     }
 }
Esempio n. 11
0
        void VisitCircle(Visitor visitor, Map map, ICoord begin_cell, ICoord end_cell)
        {
            //here is an algorithm for 'filling' circum-squared octagon
            uint x_shift = (uint)Math.Ceiling((end_cell.X_coord - begin_cell.X_coord) * 0.3f - 0.5f);
            //lets calculate x_start/x_end coords for central strip...
            uint x_start = begin_cell.X_coord + x_shift;
            uint x_end   = end_cell.X_coord - x_shift;

            //visit central strip with constant width...
            for (uint x = x_start; x <= x_end; ++x)
            {
                for (uint y = begin_cell.Y_coord; y <= end_cell.Y_coord; ++y)
                {
                    CellCoord cellCoord = new CellCoord(x, y);
                    Cell      r_zone    = new Cell(cellCoord);
                    r_zone.data.nocreate = data.nocreate;
                    map.Visit(r_zone, visitor);
                }
            }

            //if x_shift == 0 then we have too small cell area, which were already
            //visited at previous step, so just return from procedure...
            if (x_shift == 0)
            {
                return;
            }

            uint y_start = end_cell.Y_coord;
            uint y_end   = begin_cell.Y_coord;

            //now we are visiting borders of an octagon...
            for (uint step = 1; step <= (x_start - begin_cell.X_coord); ++step)
            {
                //each step reduces strip height by 2 cells...
                y_end   += 1;
                y_start -= 1;
                for (uint y = y_start; y >= y_end; --y)
                {
                    //we visit cells symmetrically from both sides, heading from center to sides and from up to bottom
                    //e.g. filling 2 trapezoids after filling central cell strip...
                    CellCoord cellCoord_left = new CellCoord(x_start - step, y);
                    Cell      r_zone_left    = new Cell(cellCoord_left);
                    r_zone_left.data.nocreate = data.nocreate;
                    map.Visit(r_zone_left, visitor);

                    //right trapezoid cell visit
                    CellCoord cellCoord_right = new CellCoord(x_end + step, y);
                    Cell      r_zone_right    = new Cell(cellCoord_right);
                    r_zone_right.data.nocreate = data.nocreate;
                    map.Visit(r_zone_right, visitor);
                }
            }
        }
Esempio n. 12
0
 private void button_extend_Click(object sender, EventArgs e)
 {
     if (cnc != null)
     {
         ICoord p = initialPos.Clone();
         p.Y += extendY;
         p.Z += extendZ;
         cnc.SendMovePos(cnc.Position, p, SPEED);
         outputTextBox.SelectionColor = Color.Orange;
         outputTextBox.AppendText("Extend the robotic arm!\n");
         oneAngleButton.Enabled = oneRowButton.Enabled = allButton.Enabled = true;
     }
 }
Esempio n. 13
0
 private void oneRowButton_Click(object sender, EventArgs e)
 {
     if (cnc != null)
     {
         for (int i = range; i > -range; i--)
         {
             ICoord pos = cnc.Position.Clone();
             pos.X += (i * 5) * Metrics.unitPerDegree;
             generateMarksForPos(pos);
         }
         checkBoxZigZag.Checked = checkBoxZigZag.Enabled = false;
     }
 }
Esempio n. 14
0
        private void marksListBox_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int index = marksListBox.IndexFromPoint(e.Location);

            if (index != System.Windows.Forms.ListBox.NoMatches && cnc != null)
            {
                ICoord pos = marks[index];
                cnc.SendMovePos(cnc.Position, pos, SPEED);
                outputTextBox.SelectionColor = Color.Blue;
                outputTextBox.AppendText(String.Format("[{0}] Go to mark [{1}]({2:0.00},{3:0.00},{4:0.00})\r\n",
                                                       DateTime.Now.ToString("h:mm:ss"), index + 1, pos.X, pos.Y, pos.Z));
                outputTextBox.ScrollToCaret();
            }
        }
Esempio n. 15
0
        private void buttonGeneratePanoMarks_Click(object sender, EventArgs e)
        {
            int count   = Convert.ToInt32(numericUpDownCountPanoMarks.Value);
            int r_count = count * range / 36;

            if (cnc != null && count > 0)
            {
                for (int i = r_count / 2; i > -r_count / 2; i--)
                {
                    ICoord pos = cnc.Position.Clone();
                    pos.X += (i * 360.0 / count) * Metrics.unitPerDegree;
                    addMark(pos, true);
                }
                checkBoxZigZag.Checked = checkBoxZigZag.Enabled = false;
            }
        }
Esempio n. 16
0
        public static bool __Parallel(this ICoord coord1, ICoord coord2, double tolerance = Tolerance)
        {
            int result;

            UFSession.GetUFSession().Vec3.IsParallel(coord1.ToCoord(), coord2.ToCoord(), tolerance, out result);
            switch (result)
            {
            case UFConstants.TRUE:
                return(true);

            case UFConstants.FALSE:
                return(false);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 17
0
 private void allButton_Click(object sender, EventArgs e)
 {
     if (cnc != null)
     {
         for (int i = 0; i < 8; i++)
         {
             double phi = i * 5;
             for (int j = range; j > -range; j--)
             {
                 double theta = j * 5;
                 ICoord pos   = cnc.Position.Clone();
                 relativeTP(theta, phi, ref pos);
                 generateMarksForPos(pos, true);
             }
         }
         checkBoxZigZag.Enabled = true;
     }
 }
Esempio n. 18
0
        public void generateMarksForPos(ICoord pos, bool quiet = false)
        {
            double theta = 0, phi = 0;

            relativePos(pos, ref theta, ref phi);
            double delta = 1;
            double pd1, td1, pd2, td2, pd3, td3, pd4, td4, pd5, td5, pd6, td6;

            pd6 = delta * Metrics.unitPerDegree;
            td6 = 0;

            pd3 = -delta * Metrics.unitPerDegree;
            td3 = 0;

            double phi_r   = phi * Math.PI / 180;
            double delta_r = delta * Math.PI / 180;

            double delta_phi_r = Math.Asin(Math.Sin(delta_r) / 2);
            double delta_phi   = delta_phi_r * 180 / Math.PI;

            pd5 = pd1 = delta_phi * Metrics.unitPerDegree;
            pd4 = pd2 = -delta_phi * Metrics.unitPerDegree;

            double delta_theta_r = Math.Acos((Math.Cos(delta_r) - Math.Sin(phi_r) * Math.Sin(phi_r + delta_phi_r)) /
                                             (Math.Cos(phi_r) * Math.Cos(phi_r + delta_phi_r)));
            double delta_theta = delta_theta_r * 180 / Math.PI;

            td5 = -delta_theta * Metrics.unitPerDegree;
            td1 = delta_theta * Metrics.unitPerDegree;

            delta_theta_r = Math.Acos((Math.Cos(delta_r) - Math.Sin(phi_r) * Math.Sin(phi_r - delta_phi_r)) /
                                      (Math.Cos(phi_r) * Math.Cos(phi_r - delta_phi_r)));
            delta_theta = delta_theta_r * 180 / Math.PI;
            td4         = -delta_theta * Metrics.unitPerDegree;
            td2         = delta_theta * Metrics.unitPerDegree;

            addMark(pos, quiet);
            addMark(pos.X + td1, pos.Y + pd1, pos.Z + pd1, quiet);
            addMark(pos.X + td2, pos.Y + pd2, pos.Z + pd2, quiet);
            addMark(pos.X + td3, pos.Y + pd3, pos.Z + pd3, quiet);
            addMark(pos.X + td4, pos.Y + pd4, pos.Z + pd4, quiet);
            addMark(pos.X + td5, pos.Y + pd5, pos.Z + pd5, quiet);
            addMark(pos.X + td6, pos.Y + pd6, pos.Z + pd6, quiet);
        }
Esempio n. 19
0
        void OnUpdate()
        {
            lblBuf2.Text = cnc.BufferFree.ToString() + "/" + cnc.BufferSize.ToString();

            lblPos2.Text = cnc.Position.ToString();
            lblSpd2.Text = cnc.Speed.ToString("#0.00");

            lblOut2.Text = cnc.Output.ToString("X") + (cnc.EStop ? " E" : "") + (cnc.Pause ? " P" : "");

            lblLim2.Text    = cnc.Limit.ToString("X");
            lblLimRaw2.Text = cnc.LimitRaw.ToString("X");

            lblJog2.Text    = cnc.Jog.ToString("X");
            lblJogRaw2.Text = cnc.JogRaw.ToString("X");

            ICoord delta = (Coord)cnc.Position - initialPos;

            roboticArmControl.setAngles(delta.X, delta.Y, delta.Z);
        }
Esempio n. 20
0
 private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (currentCameraType == CameraType.GoPro && GoProControl.streaming &&
         DialogResult.Yes == MessageBox.Show("Are you going to stop GoPro Streaming?", "Before closing", MessageBoxButtons.YesNo))
     {
         goPro.stopStreaming();
         e.Cancel = true;
     }
     if (cnc != null)
     {
         ICoord delta = (Coord)cnc.Position - initialPos;
         if ((delta.X <= 0.001 && delta.Y <= 0.001 && delta.Z <= 0.001) ||
             DialogResult.No == MessageBox.Show("Are you going to reset Robotic Arm to initial position?", "Before closing", MessageBoxButtons.YesNo))
         {
             cnc.Dispose();
             cnc = null;
         }
         else
         {
             cnc.SendMovePos(cnc.Position, initialPos, SPEED);
             e.Cancel = true;
         }
     }
 }
Esempio n. 21
0
		public float Dist(ICoord p) {
			return (this.Coord - p.Coord).magnitude;
		}
        private List <Edge> ReorderEdges(List <Edge> origEdges, VertexOrSite criterion)
        {
            int  i;
            int  n = origEdges.Count;
            Edge edge;

            // we're going to reorder the edges in order of traversal
            bool[] done  = new bool[n];
            int    nDone = 0;

            for (int j = 0; j < n; j++)
            {
                done [j] = false;
            }
            List <Edge> newEdges = new List <Edge> ();           // TODO: Switch to Deque if performance is a concern

            i    = 0;
            edge = origEdges [i];
            newEdges.Add(edge);
            _edgeOrientations.Add(Side.LEFT);
            ICoord firstPoint = (criterion == VertexOrSite.VERTEX) ? (ICoord)edge.leftVertex : (ICoord)edge.leftSite;
            ICoord lastPoint  = (criterion == VertexOrSite.VERTEX) ? (ICoord)edge.rightVertex : (ICoord)edge.rightSite;

            if (firstPoint == Vertex.VERTEX_AT_INFINITY || lastPoint == Vertex.VERTEX_AT_INFINITY)
            {
                return(new List <Edge> ());
            }

            done [i] = true;
            ++nDone;

            while (nDone < n)
            {
                for (i = 1; i < n; ++i)
                {
                    if (done [i])
                    {
                        continue;
                    }
                    edge = origEdges [i];
                    ICoord leftPoint  = (criterion == VertexOrSite.VERTEX) ? (ICoord)edge.leftVertex : (ICoord)edge.leftSite;
                    ICoord rightPoint = (criterion == VertexOrSite.VERTEX) ? (ICoord)edge.rightVertex : (ICoord)edge.rightSite;
                    if (leftPoint == Vertex.VERTEX_AT_INFINITY || rightPoint == Vertex.VERTEX_AT_INFINITY)
                    {
                        return(new List <Edge> ());
                    }
                    if (leftPoint == lastPoint)
                    {
                        lastPoint = rightPoint;
                        _edgeOrientations.Add(Side.LEFT);
                        newEdges.Add(edge);
                        done [i] = true;
                    }
                    else if (rightPoint == firstPoint)
                    {
                        firstPoint = leftPoint;
                        _edgeOrientations.Insert(0, Side.LEFT);                          // TODO: Change datastructure if this is slow
                        newEdges.Insert(0, edge);
                        done [i] = true;
                    }
                    else if (leftPoint == firstPoint)
                    {
                        firstPoint = rightPoint;
                        _edgeOrientations.Insert(0, Side.RIGHT);
                        newEdges.Insert(0, edge);
                        done [i] = true;
                    }
                    else if (rightPoint == lastPoint)
                    {
                        lastPoint = leftPoint;
                        _edgeOrientations.Add(Side.RIGHT);
                        newEdges.Add(edge);
                        done [i] = true;
                    }
                    if (done [i])
                    {
                        ++nDone;
                    }
                }
            }

            return(newEdges);
        }
Esempio n. 23
0
 public float Dist(ICoord p)
 {
     return(Vector2.Distance(p.Coord, this._coord));
 }
Esempio n. 24
0
 internal float Dist(ICoord p)
 {
     return Utilities.Distance(p.Coord(), this._coord);
 }
Esempio n. 25
0
 void ResizeBorders(ref ICoord begin_cell, ref ICoord end_cell)
 {
     begin_cell = low_bound;
     end_cell   = high_bound;
 }
Esempio n. 26
0
 public float Distance(ICoord p) {
     return Point.Distance(p.Coord, Coord);
 }
Esempio n. 27
0
        /// Va gérer les clicks sur la map en fonction du mode dans lequel on se trouve
        private void myMap_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            UpdateStatusBar("MouseLeftButtonDown");
            if (status != null)
            {
                System.Windows.Point mousePosition = e.GetPosition(myMap);
                ICoord     obj;
                bool       trouve = false;
                List <int> index = new List <int>();
                double     distancemin, distanceTmp;

                Location loc = new Location();
                loc = myMap.ViewportPointToLocation(mousePosition);

                int i = 0, distPos = 0;
                ///ISPointClose
                ///On cherche les CartoObj proche
                foreach (ICartoObj cartoObj in mP.CartoCollection)
                {
                    Console.WriteLine("Test : cartoObj = " + cartoObj);
                    Console.WriteLine("location = " + loc.Latitude + " / " + loc.Longitude);
                    if (cartoObj.IsPointClose(loc.Latitude, loc.Longitude, mP.Precision) == true)
                    {
                        Console.WriteLine("IS POINT CLOSE TRUE");
                        trouve = true;
                        index.Add(i);
                        //obj = cartoObj.WhichPointIsClose(e.GetPosition(myMap).X,e.GetPosition(myMap).Y);
                    }
                    i++;
                }

                if (trouve)
                {
                    Console.WriteLine("ON A TROUVE UN POINT PROCHE");
                    ///On va devoir trouver quel CartoObj est le plus proche
                    ICoord[] objtmp = new ICoord[index.Count];

                    i = 0;
                    for (int j = 0; j < index.Count; j++)
                    {
                        objtmp[i] = mP.CartoCollection[index[j]].WhichPointIsClose(loc.Latitude, loc.Longitude);
                        i        += 1;
                    }
                    ///Comparer la distance entre chaque
                    i           = 0;
                    distancemin = -1;

                    foreach (ICoord coord in objtmp)
                    {
                        Console.WriteLine("Comparaison avec le point : " + coord.X + "/" + coord.Y);
                        Console.WriteLine("Point click : " + loc.Latitude + "/" + loc.Longitude);
                        distanceTmp = MathUtil.DistanceDeuxPoints(coord.X, coord.Y, loc.Latitude, loc.Longitude);
                        if (distancemin == -1)
                        {
                            distancemin = distanceTmp;
                            distPos     = i;
                        }
                        if (distancemin > distanceTmp)
                        {
                            distancemin = distanceTmp;
                            distPos     = i;
                        }
                        i += 1;
                    }
                    Console.WriteLine("Point le plus proche : " + objtmp[distPos].X + "/" + objtmp[distPos].Y);
                    ///Arriver ici, nous avons les coordonnées du point le plus proche
                    if (objtmp[distPos] is POI)
                    {
                        if (RBPoi.IsChecked == true)
                        {
                            ///Pas de superposition de pushpin
                            loc = new Location();
                            loc = myMap.ViewportPointToLocation(mousePosition);
                            obj = new POI(loc.Latitude, loc.Longitude);
                        }
                        else
                        {
                            obj = objtmp[distPos];
                            loc = new Location(obj.X, obj.Y);
                        }
                    }
                    else
                    {
                        if (RBPoi.IsChecked == true)
                        {
                            obj = new POI(objtmp[distPos].X, objtmp[distPos].Y);
                        }
                        else
                        {
                            obj = objtmp[distPos];
                        }

                        loc = new Location(obj.X, obj.Y);
                    }
                }
                else
                {
                    Console.WriteLine("ON A PAS TROUVE DE POINT PROCHE");
                    loc = new Location();
                    loc = myMap.ViewportPointToLocation(mousePosition);
                    Console.WriteLine("Loc = " + loc.Latitude + "/ " + loc.Longitude);
                    if (status == "Créer")
                    {
                        if (RBPoi.IsChecked == true)
                        {
                            obj = new POI(loc.Latitude, loc.Longitude);
                        }
                        else
                        {
                            obj = new Coordonnees(loc.Latitude, loc.Longitude);
                        }
                    }
                    else
                    {
                        obj = null; ///Ne plus avoir l'erreur ligne 262 (utilisation d'une variable non assigné)
                    }
                }
                index.Clear();

                Console.WriteLine("Location = ", loc.Longitude + " / " + loc.Latitude);
                switch (status)
                {
                case "Créer":
                {
                    UpdateStatusBar("MouseLeftButtonDownCréer");

                    if (RBPoi.IsChecked == true)
                    {
                        Pushpin pin = new Pushpin();
                        pin.Location = loc;
                        myMap.Children.Add(pin);
                        mP.AddCartObj(obj as POI);
                        Console.WriteLine("Test après add : " + mP.CartoCollection.Last().lCoord.Last());

                        UpdateStatusBar(mP.CartoCollection.Last().ToString());
                        //ListBoxMyPersonalData.Items.Add(new POI(loc.Latitude,loc.Longitude));
                    }
                    if (RBPolyline.IsChecked == true)
                    {
                        if (coordTmp.Count == 0)
                        {
                            maPolyline = new MapPolyline();
                            myMap.Children.Add(maPolyline);
                            locCol = new LocationCollection();
                            maPolyline.Locations       = locCol;
                            maPolyline.StrokeThickness = mP.lineEp;
                            maPolyline.Stroke          = ToBrush(mP.Contour);
                            maPolyline.Opacity         = mP.Opacity;
                        }


                        if (coordTmp.Count > 2)
                        {
                            if ((coordTmp[0].X <= obj.X + mP.Precision && coordTmp[0].X >= obj.X - mP.Precision) && (coordTmp[0].Y <= obj.Y + mP.Precision && coordTmp[0].Y >= obj.Y - mP.Precision))
                            {
                                ///Notre polyline est revenu a son point de départ -> Polygon ?
                                MessageBoxResult res = MessageBox.Show("Voulez-vous en faire un polygon ? ", "Polygon", MessageBoxButton.YesNo);
                                if (res == MessageBoxResult.Yes)
                                {
                                    ///On va enfaire un polygon

                                    maPolygon = new MapPolygon();
                                    myMap.Children.Add(maPolygon);
                                    maPolygon.Locations       = locCol;
                                    maPolygon.StrokeThickness = mP.lineEp;
                                    maPolygon.Stroke          = ToBrush(mP.Contour);
                                    maPolygon.Fill            = ToBrush(mP.Remplissage);
                                    maPolygon.Opacity         = mP.Opacity;
                                    maPolygon.Locations       = maPolyline.Locations;
                                    RBPolygon.IsChecked       = true;
                                    RBPolyline.IsChecked      = false;
                                    ButtonFinirTrace_Click(null, null);

                                    return;
                                }
                            }
                        }
                        maPolyline.Locations.Add(loc);

                        coordTmp.Add(obj);
                    }
                    if (RBPolygon.IsChecked == true)
                    {
                        if (coordTmp.Count == 0)
                        {
                            maPolygon = new MapPolygon();
                            myMap.Children.Add(maPolygon);
                            locCol = new LocationCollection();
                            maPolygon.Locations       = locCol;
                            maPolygon.StrokeThickness = mP.lineEp;
                            maPolygon.Stroke          = ToBrush(mP.Contour);
                            maPolygon.Fill            = ToBrush(mP.Remplissage);
                            maPolygon.Opacity         = mP.Opacity;
                        }
                        coordTmp.Add(obj);

                        maPolygon.Locations.Add(loc);
                    }
                    break;
                }

                case "Supprimer":
                {
                    Console.WriteLine("Supprimer");
                    if (trouve)
                    {
                        bool find = false;
                        int  j = 0, a = 0;

                        ///On sait sur quel point/figure on clique, on doit retrouver la position de chaque
                        while (j < mP.CartoCollection.Count && find == false)
                        {
                            a = 0;
                            while (a < mP.CartoCollection[j].lCoord.Count && find == false)
                            {
                                if (mP.CartoCollection[j].lCoord[a].X == loc.Latitude && mP.CartoCollection[j].lCoord[a].Y == loc.Longitude)
                                {
                                    find = true;
                                }
                                else
                                {
                                    a++;
                                }
                            }
                            if (!find)
                            {
                                j++;
                            }
                        }
                        if (find)
                        {
                            Console.WriteLine("TROUVE");
                            // J contient l'index de la figure contenant le point sélectionné
                            myMap.Children.Remove(myMap.Children[j]);
                            mP.CartoCollection.Remove(mP.CartoCollection[j]);
                            //ListBoxMyPersonalData.Items.Refresh();
                        }
                    }

                    break;
                }

                case "Modifier":
                {
                    ///On va récupérer l'index
                    if (trouve)
                    {
                        bool find = false;
                        int  j = 0, a = 0;
                        while (j < mP.CartoCollection.Count && find == false)
                        {
                            a = 0;
                            while (a < mP.CartoCollection[j].lCoord.Count && find == false)
                            {
                                if (mP.CartoCollection[j].lCoord[a].X == loc.Latitude && mP.CartoCollection[j].lCoord[a].Y == loc.Longitude)
                                {
                                    find = true;
                                }
                                else
                                {
                                    a++;
                                }
                            }
                            if (!find)
                            {
                                j++;
                            }
                        }
                        if (find)
                        {
                            WindowItemProperty wItem = new WindowItemProperty(j);
                            wItem.ShowDialog();

                            ListBoxMyPersonalData.Items.Refresh();
                            RefreshMap();
                        }
                    }


                    break;
                }
                }
            }
        }
Esempio n. 28
0
 public void Move(ICoord vec)
 {
 }
		public float Dist (ICoord p)
		{
			return Vector2.Distance (p.Coord, this._coord);
		}
Esempio n. 30
0
 public double Dist(ICoord p)
 {
     return(Point.Distance(p.GetCoord(), this.coord));
 }
Esempio n. 31
0
        private List <Edge> ReorderEdges(List <Edge> origEdges, VertexOrSite criterion)
        {
            int count = origEdges.Count;

            bool[] array = new bool[count];
            int    num   = 0;

            for (int i = 0; i < count; i++)
            {
                array[i] = false;
            }
            List <Edge> list = new List <Edge>();
            int         num2 = 0;
            Edge        edge = origEdges[num2];

            list.Add(edge);
            _edgeOrientations.Add(Side.LEFT);
            object obj;

            if (criterion == VertexOrSite.VERTEX)
            {
                ICoord leftVertex = edge.leftVertex;
                obj = leftVertex;
            }
            else
            {
                obj = edge.leftSite;
            }
            ICoord coord = (ICoord)obj;
            object obj2;

            if (criterion == VertexOrSite.VERTEX)
            {
                ICoord leftVertex = edge.rightVertex;
                obj2 = leftVertex;
            }
            else
            {
                obj2 = edge.rightSite;
            }
            ICoord coord2 = (ICoord)obj2;

            if (coord == Vertex.VERTEX_AT_INFINITY || coord2 == Vertex.VERTEX_AT_INFINITY)
            {
                return(new List <Edge>());
            }
            array[num2] = true;
            num++;
            while (num < count)
            {
                for (num2 = 1; num2 < count; num2++)
                {
                    if (!array[num2])
                    {
                        edge = origEdges[num2];
                        object obj3;
                        if (criterion == VertexOrSite.VERTEX)
                        {
                            ICoord leftVertex = edge.leftVertex;
                            obj3 = leftVertex;
                        }
                        else
                        {
                            obj3 = edge.leftSite;
                        }
                        ICoord coord3 = (ICoord)obj3;
                        object obj4;
                        if (criterion == VertexOrSite.VERTEX)
                        {
                            ICoord leftVertex = edge.rightVertex;
                            obj4 = leftVertex;
                        }
                        else
                        {
                            obj4 = edge.rightSite;
                        }
                        ICoord coord4 = (ICoord)obj4;
                        if (coord3 == Vertex.VERTEX_AT_INFINITY || coord4 == Vertex.VERTEX_AT_INFINITY)
                        {
                            return(new List <Edge>());
                        }
                        if (coord3 == coord2)
                        {
                            coord2 = coord4;
                            _edgeOrientations.Add(Side.LEFT);
                            list.Add(edge);
                            array[num2] = true;
                        }
                        else if (coord4 == coord)
                        {
                            coord = coord3;
                            _edgeOrientations.Insert(0, Side.LEFT);
                            list.Insert(0, edge);
                            array[num2] = true;
                        }
                        else if (coord3 == coord)
                        {
                            coord = coord4;
                            _edgeOrientations.Insert(0, Side.RIGHT);
                            list.Insert(0, edge);
                            array[num2] = true;
                        }
                        else if (coord4 == coord2)
                        {
                            coord2 = coord3;
                            _edgeOrientations.Add(Side.RIGHT);
                            list.Add(edge);
                            array[num2] = true;
                        }
                        if (array[num2])
                        {
                            num++;
                        }
                    }
                }
            }
            return(list);
        }
Esempio n. 32
0
 public Coordinate(ICoord iCoord) : this(iCoord.X, iCoord.Y, iCoord.Z)
 {
 }
Esempio n. 33
0
 public float Dist(ICoord p)
 {
     return((this.Coord - p.Coord).magnitude);
 }
Esempio n. 34
0
        private List <Edge> ReorderEdges(List <Edge> origEdges, Type criterion)
        {
            int  i;
            int  j;
            int  n = origEdges.Count;
            Edge edge;
            // we're going to reorder the edges in order of traversal
            List <bool> done  = new List <bool>(n);
            int         nDone = 0;

            for (int o = 0; o < n; o++)
            {
                done.Add(false);
            }
            List <Edge> newEdges = new List <Edge>();

            i    = 0;
            edge = origEdges[i];
            newEdges.Add(edge);
            _edgeOrientations.Add(LR.LEFT);
            ICoord firstPointF = null;
            ICoord lastPointF  = null;

            if ((criterion == typeof(Vertex)))
            {
                firstPointF = edge.LeftVertex;
                lastPointF  = edge.RightVertex;
            }
            else
            {
                firstPointF = edge.LeftSite;
                lastPointF  = edge.RightSite;
            }

            if (firstPointF == Vertex.VERTEX_AT_INFINITY || lastPointF == Vertex.VERTEX_AT_INFINITY)
            {
                return(new List <Edge>());
            }

            done[i] = true;
            ++nDone;

            while (nDone < n)
            {
                for (i = 1; i < n; ++i)
                {
                    if (done[i])
                    {
                        continue;
                    }
                    edge = origEdges[i];
                    ICoord leftPointF  = null;
                    ICoord rightPointF = null;
                    if ((criterion == typeof(Vertex)))
                    {
                        leftPointF  = edge.LeftVertex;
                        rightPointF = edge.RightVertex;
                    }
                    else
                    {
                        leftPointF  = edge.LeftSite;
                        rightPointF = edge.RightSite;
                    }
                    if (leftPointF == Vertex.VERTEX_AT_INFINITY || rightPointF == Vertex.VERTEX_AT_INFINITY)
                    {
                        return(new List <Edge>());
                    }
                    if (leftPointF == lastPointF)
                    {
                        lastPointF = rightPointF;
                        _edgeOrientations.Add(LR.LEFT);
                        newEdges.Add(edge);
                        done[i] = true;
                    }
                    else if (rightPointF == firstPointF)
                    {
                        firstPointF = leftPointF;
                        _edgeOrientations.Insert(0, LR.LEFT);
                        newEdges.Insert(0, edge);
                        done[i] = true;
                    }
                    else if (leftPointF == firstPointF)
                    {
                        firstPointF = rightPointF;
                        _edgeOrientations.Insert(0, LR.RIGHT);
                        newEdges.Insert(0, edge);
                        done[i] = true;
                    }
                    else if (rightPointF == lastPointF)
                    {
                        lastPointF = leftPointF;
                        _edgeOrientations.Add(LR.RIGHT);
                        newEdges.Add(edge);
                        done[i] = true;
                    }
                    if (done[i])
                    {
                        ++nDone;
                    }
                }
            }
            return(newEdges);
        }
Esempio n. 35
0
 public void Move(ICoord vec)
 {
 }