Ejemplo n.º 1
0
        protected override void RemoveSignal(OxyPlot.Series.Series series)
        {
            if (series == null)
            {
                return;
            }

            PlotSignalModel signal = (PlotSignalModel)series.Tag;

            //this.paneModel.Signals.Remove(signal);

            PlotModel.Series.Remove(series);

            OxyPlot.Series.LineSeries lax = series as OxyPlot.Series.LineSeries;
            if (lax != null)
            {
                PlotModel.Axes.Remove(lax.YAxis);
            }

            if (SelectedSeries == series)
            {
                SelectedSeries = null;
            }

            PlotModel.InvalidatePlot(false);
        }
Ejemplo n.º 2
0
        protected PlotSignalModel internalAddSignal(ISignalViewModel signal)
        {
            PluginFramework.Sample[] data = signal.GetData();
            var lineSerie = new OxyPlot.Series.LineSeries
            {
                StrokeThickness             = 1,
                CanTrackerInterpolatePoints = false,
                Title               = signal.Title,
                Decimator           = Decimator.Decimate,
                TrackerFormatString = "{1}: \t{2:HH:mm:ss}\n{3}: \t{4}"
            };

            lineSerie.Points.Capacity = data.GetLength(0);
            for (int i = 0; i < data.GetLength(0); i++)
            {
                lineSerie.Points.Add(OxyPlot.Axes.DateTimeAxis.CreateDataPoint(data[i].Time, data[i].Value));
            }

            // Create axis
            var valueAxis = new OxyPlot.Axes.LinearAxis()
            {
                MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = signal.Title
            };

            valueAxis.Key          = signal.Title;
            valueAxis.Position     = axisPosition;
            axisPosition           = (axisPosition == AxisPosition.Left ? AxisPosition.Right : AxisPosition.Left);
            valueAxis.TextColor    = lineSerie.MarkerStroke;
            valueAxis.PositionTier = PlotModel.Axes.Count;
            valueAxis.Unit         = signal.Unit;
            PlotModel.Axes.Add(valueAxis);

            lineSerie.YAxisKey = signal.Title;
            PlotSignalModel ps = new PlotSignalModel()
            {
                Path = signal.GetPath()
            };

            lineSerie.Tag = ps;
            //lineSerie.MouseDown += lineSerie_MouseDown;
            PlotModel.Series.Add(lineSerie);
            PlotModel.InvalidatePlot(true);
            return(ps);
        }
Ejemplo n.º 3
0
        private void Project_FilesRealigned(object sender, EventArgs e)
        {
            foreach (OxyPlot.Series.LineSeries serie in PlotModel.Series)
            {
                PlotSignalModel plotSignal = (PlotSignalModel)serie.Tag;

                var signalModel = ProjectViewModel.GetSignal(plotSignal.Path);
                if (signalModel != null)
                {
                    PluginFramework.Sample[] data = signalModel.GetData();
                    serie.Points.Clear();
                    serie.Points.Capacity = data.GetLength(0);
                    for (int i = 0; i < data.GetLength(0); i++)
                    {
                        serie.Points.Add(OxyPlot.Axes.DateTimeAxis.CreateDataPoint(data[i].Time, data[i].Value));
                    }
                }
            }

            plotModel.InvalidatePlot(true);
        }
Ejemplo n.º 4
0
        protected virtual PlotSignalModel internalAddSignal(ISignalViewModel signal, Axis lastDroppedAxis)
        {
            PlotSignalModel ps = new PlotSignalModel()
            {
                Path = signal.GetPath(), Axis = lastDroppedAxis.Key
            };
            var ax = PlotModel.GetAxisOrDefault(ps.Axis, xAxis);

            ax.Title = signal.Title;

            if (lastDroppedAxis == xAxis)
            {
                xSignal = signal;
                //var ySignal = (from PlotSignalModel s in model.Signals where s.Axis == "Y" select s).First();
            }
            else if (lastDroppedAxis == yAxis)
            {
                ySignal = signal;
            }

            if (xSignal == null || ySignal == null)
            {
                PlotModel.InvalidatePlot(true);
                return(ps);
            }

            var xdata = xSignal.GetData();
            var ydata = ySignal.GetData();

            var scatterSerie = new OxyPlot.Series.ScatterSeries()
            {
                MarkerType   = OxyPlot.MarkerType.Cross,
                MarkerSize   = 2,
                MarkerStroke = OxyColors.Blue,
                //Title = xSignal.Title + "/" + ySignal.Title,
                TrackerFormatString = "{1}: \t{2}\n{3}: \t{4}"
            };

            // Find pixel size here
            scatterSerie.BinSize = 4;

            List <DataPoint> dataPoints = new List <DataPoint>(xdata.GetLength(0));

            for (int i = 0; i < xdata.GetLength(0); i++)
            {
                DataPoint dp = new DataPoint();
                dp.X            = xdata[i].Value;
                dp.Y            = ydata[i].Value;
                dp.T            = xdata[i].Time;
                dp.ScatterPoint = new OxyPlot.Series.ScatterPoint(xdata[i].Value, ydata[i].Value);
                dataPoints.Add(dp);
                //scatterSerie.Points.Add(new OxyPlot.Series.ScatterPoint(xdata[i].Value, ydata[i].Value,double.NaN, double.NaN, xdata[i].Time));
            }
            scatterSerie.ItemsSource = dataPoints;
            scatterSerie.Mapping     = Filter;
            scatterSerie.XAxisKey    = "X";
            scatterSerie.YAxisKey    = "Y";

            PlotModel.Series.Add(scatterSerie);

            //double a, b;
            //LeastSquaresFit(scatterSerie.Points, out a, out b);
            //PlotModel.Annotations.Add(new LineAnnotation { Slope = a, Intercept = b, Text = "Least squares fit" });
            PlotModel.InvalidatePlot(true);
            return(ps);
        }