Ejemplo n.º 1
0
        private void SetCodeString(GraphFunction value)
        {
            if (selectedFunction != null)
                selectedFunction.Code = CodeDocument.Text;

            CodeDocument.Text = value.Code;
        }
Ejemplo n.º 2
0
        private void RemoveFunction(GraphFunction function)
        {
            Functions.Remove(function);
            if (function.PlotSeries != null)
                PlotModel.Series.Remove(function.PlotSeries);
            if (function.DerivedSeries != null)
                PlotModel.Series.Remove(function.DerivedSeries);
            if (function.IntegralSeries != null)
                PlotModel.Series.Remove(function.IntegralSeries);

            PlotModel.InvalidatePlot(true);
        }
Ejemplo n.º 3
0
        private void InitFunctionSeries(GraphFunction function)
        {
            if (function.PlotSeries == null)
            {
                function.PlotSeries = new LineSeries();
                function.PlotSeries.Color = GetNextColor();
                PlotModel.Series.Add(function.PlotSeries);

                function.Color = new SolidColorBrush(oxy.ConverterExtensions.ToColor(function.PlotSeries.ActualColor));
            }
            if (function.DerivedSeries == null)
            {
                function.DerivedSeries = new LineSeries();
                function.DerivedSeries.Color = function.PlotSeries.ActualColor;
                function.DerivedSeries.LineStyle = LineStyle.Dash;
                PlotModel.Series.Add(function.DerivedSeries);
            }
            if (function.IntegralSeries == null)
            {
                function.IntegralSeries = new AreaSeries();
                function.IntegralSeries.Color = function.PlotSeries.ActualColor;
                PlotModel.Series.Add(function.IntegralSeries);
            }
        }
Ejemplo n.º 4
0
        private void applyFunction(GraphFunction func)
        {
            suppressOutput = true;
            SchemeMathWrapper.VerifyIsProcedure(func.Code);
            suppressOutput = false;

            InitFunctionSeries(func);

            var xydata = SchemeMathWrapper.CalcPlotData(func.Code, XMin, XMax, func.Step);
            var xydatapoints = xydata.Select((xy) => new DataPoint(xy.Item1, xy.Item2));
            func.PlotSeries.Points.Clear();
            func.PlotSeries.Points.AddRange(xydatapoints);
            func.PlotSeries.Title = func.Name;

            if (func.ShowDerivative)
            {
                var dxydata = SchemeMathWrapper.CalcDerivedPlotData(func.Code, XMin, XMax, func.Step);
                var dxydatapoints = dxydata.Select((xy) => new DataPoint(xy.Item1, xy.Item2));
                func.DerivedSeries.Points.Clear();
                func.DerivedSeries.Points.AddRange(dxydatapoints);
                func.DerivedSeries.Title = "'" + func.Name;

            }

            if (func.ShowIntegral)
            {
                IEnumerable<System.Tuple<double, double>> coords;

                if (func.IsLeftIntegral)
                    coords = SchemeMathWrapper.CalcLeftIntegralCoords(func.Code, func.IntegralMin,
                        func.IntegralMax, func.IntegralRes);
                else if (func.IsMiddleIntegral)
                    coords = SchemeMathWrapper.CalcMidpointIntegralCoords(func.Code, func.IntegralMin,
                        func.IntegralMax, func.IntegralRes);
                else if (func.IsRightIntegral)
                    coords = SchemeMathWrapper.CalcRightIntegralCoords(func.Code, func.IntegralMin,
                        func.IntegralMax, func.IntegralRes);
                else
                    throw new ArgumentException("Integral mode not selected!");

                var deltaX = SchemeMathWrapper.CalcDeltaX(func.IntegralMin,
                    func.IntegralMax, func.IntegralRes);

                func.IntegralSeries.Points.Clear();
                func.IntegralSeries.Points2.Clear();
                foreach (var coord in coords)
                {
                    func.IntegralSeries.Points.Add(new DataPoint(coord.Item1, coord.Item2));
                    func.IntegralSeries.Points.Add(new DataPoint(coord.Item1 + deltaX, coord.Item2));
                }

                var bottomLineSeries = new LineSeries();
                func.IntegralSeries.Points2.Add(new DataPoint(func.IntegralMin, 0));
                func.IntegralSeries.Points2.Add(new DataPoint(func.IntegralMax, 0));

                var area = SchemeMathWrapper.CalcDefiniteIntegral(func.IntegralMin,
                    func.IntegralMax, func.IntegralRes, coords);

                func.IntegralSeries.Title = "''" + func.Name + "(A: " + area.ToString("G5") + ")";
            }

            SetFunctionVisibility(func);
        }
Ejemplo n.º 5
0
 private void AddFunction()
 {
     var func = new GraphFunction();
     func.Samples = SchemeMathWrapper.StepToSamples(XMin, XMax, func.Step);
     func.PropertyChanged += function_propertyChanged;
     Functions.Add(func);
 }
Ejemplo n.º 6
0
 private static void SetFunctionVisibility(GraphFunction function)
 {
     function.PlotSeries.IsVisible = function.IsEnabled;
     function.DerivedSeries.IsVisible = function.IsEnabled && function.ShowDerivative;
     function.IntegralSeries.IsVisible = function.IsEnabled && function.ShowIntegral;
 }