コード例 #1
0
        public void OnAfterFittingStep()
        {
            if (_view != null)
            {
                _view.SetChiSquare(this._chiSquare);
            }



            if (_doc.FitContext is Altaxo.Graph.GUI.GraphController)
            {
                // for every dependent variable in the FitEnsemble, create a function graph
                Altaxo.Graph.GUI.GraphController graph = _doc.FitContext as Altaxo.Graph.GUI.GraphController;

                int funcNumber = 0;
                for (int i = 0; i < _doc.FitEnsemble.Count; i++)
                {
                    FitElement fitEle = _doc.FitEnsemble[i];

                    for (int k = 0; k < fitEle.NumberOfDependentVariables; k++, funcNumber++)
                    {
                        if (funcNumber < _functionPlotItems.Count && _functionPlotItems[funcNumber] != null)
                        {
                            XYFunctionPlotItem plotItem = (XYFunctionPlotItem)_functionPlotItems[funcNumber];
                            FitFunctionToScalarFunctionDDWrapper wrapper = (FitFunctionToScalarFunctionDDWrapper)plotItem.Data.Function;
                            wrapper.Initialize(fitEle.FitFunction, k, 0, _doc.GetParametersForFitElement(i));
                        }
                        else
                        {
                            FitFunctionToScalarFunctionDDWrapper wrapper = new FitFunctionToScalarFunctionDDWrapper(fitEle.FitFunction, k, _doc.GetParametersForFitElement(i));
                            XYFunctionPlotData plotdata = new XYFunctionPlotData(wrapper);
                            XYFunctionPlotItem plotItem = new XYFunctionPlotItem(plotdata, new G2DPlotStyleCollection(LineScatterPlotStyleKind.Line));
                            graph.ActiveLayer.PlotItems.Add(plotItem);
                            _functionPlotItems.Add(plotItem);
                        }
                    }
                }

                // if there are more elements in _functionPlotItems, remove them from the graph
                for (int i = _functionPlotItems.Count - 1; i >= funcNumber; --i)
                {
                    if (_functionPlotItems[i] != null)
                    {
                        graph.ActiveLayer.PlotItems.Remove((IGPlotItem)_functionPlotItems[i]);
                        _functionPlotItems.RemoveAt(i);
                    }
                }
                graph.RefreshGraph();
            }
        }