示例#1
0
        public void InitModel2()
        {
            Model2          = GetNewModel("GetCoords4Sim");
            Model2.PlotType = PlotType.Cartesian;
            Model2.Series.Add(GetSeries4Model2("траектория1", OxyColors.SkyBlue, 0));
            Model2.Series.Add(GetSeries4Model2("траектория2", OxyColors.DarkBlue, 1));
            Model2.Series.Add(GetSeries4Model2("траектория3", OxyColors.MediumVioletRed, 2));
            Model2.Series.Add(GetSeries4Model2("траектория4", OxyColors.ForestGreen, 3));
            Model2.MouseDown += (s, e) => {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    var ser = Model2.Series[ActiveIndex] as LineSeries;
                    // Add a point to the line series.
                    ser.Points.Add(ser.InverseTransform(e.Position));
                    IndOfPointToMove[ActiveIndex] = ser.Points.Count - 1;
                    var an = new PointAnnotation()
                    {
                        Shape = MarkerType.Circle,
                        Size  = 3,
                        Fill  = ser.Color,
                        X     = ser.InverseTransform(e.Position).X,
                        Y     = ser.InverseTransform(e.Position).Y,

                        ToolTip = (ser.Points.Count - 1).ToString(),
                        Text    = PointsVisible ? (ser.Points.Count - 1).ToString() : ""
                    };
                    Annot[ActiveIndex].Add(an);
                    Model2.Annotations.Add(an);
                    Model2.InvalidatePlot(false);
                    e.Handled = true;
                }
            };
        }
示例#2
0
        public void DelLsatPoint()
        {
            if (Annot[ActiveIndex].Count == 0)
            {
                return;
            }
            var an = Annot[ActiveIndex].Last();

            Annot[ActiveIndex].Remove(an);
            Model2.Annotations.Remove(an);

            var ser = (Model2.Series[ActiveIndex] as LineSeries);

            ser.Points.RemoveAt(ser.Points.Count - 1);
            IndOfPointToMove[ActiveIndex] = -1;
            Model2.InvalidatePlot(false);
        }
示例#3
0
        public void LoadInterpList(List <TrueCoord> data)
        {
            Model2.Annotations.Clear();
            foreach (var ser in Model2.Series)
            {
                (ser as LineSeries).Points.Clear();
            }
            foreach (var item in Annot)
            {
                item.Value.Clear();
            }

            for (int i = 0; i < 4; i++)
            {
                var ser = Model2.Series[i] as LineSeries;
                IndOfPointToMove[i] = -1;
                if (data[i].X.Count < 2)
                {
                    continue;
                }
                // Add a point to the line series.
                foreach (var dp in data[i].DataPoints())
                {
                    ser.Points.Add(dp);
                    var an = new PointAnnotation()
                    {
                        Shape = MarkerType.Circle,
                        Size  = 3,
                        Fill  = ser.Color,
                        X     = dp.X,
                        Y     = dp.Y,

                        ToolTip = (ser.Points.Count - 1).ToString(),
                        Text    = PointsVisible ? (ser.Points.Count - 1).ToString() : ""
                    };

                    Annot[i].Add(an);
                    Model2.Annotations.Add(an);
                }
            }
            Model2.InvalidatePlot(false);
        }
示例#4
0
        public LineSeries GetSeries4Model2(string title, OxyColor color, int index)
        {
            var s1 = new LineSeries {
                Title = title,
                Color = color,
                //MarkerType = MarkerType.Circle,
                //MarkerSize = 6,
                //MarkerStroke = OxyColors.White,
                //MarkerFill = color,
                //MarkerStrokeThickness = 1.5
            };

            IndOfPointToMove.Add(index, -1);
            Annot.Add(index, new List <PointAnnotation>());


            // Subscribe to the mouse down event on the line series
            s1.MouseDown += (s, e) => {
                // only handle the left mouse button (right button can still be used to pan)
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    int indexOfNearestPoint = (int)Math.Round(e.HitTestResult.Index);
                    var nearestPoint        = s1.Transform(s1.Points[indexOfNearestPoint]);

                    // Check if we are near a point
                    if ((nearestPoint - e.Position).Length < 10)
                    {
                        // Start editing this point
                        IndOfPointToMove[index] = indexOfNearestPoint;
                    }
                    else
                    {
                        // otherwise create a point on the current line segment
                        //int i = (int)e.HitTestResult.Index + 1;
                        //s1.Points.Insert(i,s1.InverseTransform(e.Position));
                        //IndOfPointToMove[index] = i;
                    }

                    // Change the linestyle while editing
                    s1.LineStyle = LineStyle.DashDot;

                    // Remember to refresh/invalidate of the plot
                    Model2.InvalidatePlot(false);

                    // Set the event arguments to handled - no other handlers will be called.
                    e.Handled = true;
                }
            };

            s1.MouseMove += (s, e) =>
            {
                if (IndOfPointToMove[index] >= 0)
                {
                    // Move the point being edited.
                    s1.Points[IndOfPointToMove[index]]      = s1.InverseTransform(e.Position);
                    Annot[index][IndOfPointToMove[index]].X = s1.InverseTransform(e.Position).X;
                    Annot[index][IndOfPointToMove[index]].Y = s1.InverseTransform(e.Position).Y;
                    Model2.InvalidatePlot(false);
                    e.Handled = true;
                }
            };

            s1.MouseUp += (s, e) => {
                // Stop editing
                IndOfPointToMove[index] = -1;
                s1.LineStyle            = LineStyle.Solid;
                Model2.InvalidatePlot(false);
                e.Handled = true;
            };



            return(s1);
        }