示例#1
0
        public void Initialize(Calc.Regression.Nonlinear.FitElement fitElement)
        {
            _fitElement = fitElement;

            _numberOfX         = _fitElement.NumberOfIndependentVariables;
            _numberOfY         = _fitElement.NumberOfDependentVariables;
            _numberOfParameter = _fitElement.NumberOfParameters;

            _totalSlots = Math.Max(_numberOfParameter, _numberOfX + _numberOfY + 4);
            SetupElements();
        }
        void Select(IFitFunction func)
        {
            bool changed = false;

            if (_doc.FitEnsemble.Count == 0) // Fitting is fresh, we can add the function silently
            {
                FitElement newele = new FitElement();
                newele.FitFunction = func;
                _doc.FitEnsemble.Add(newele);
                _doc.SetDefaultParametersForFitElement(0);
                changed = true;
            }
            else if (_doc.FitEnsemble.Count > 0 && _doc.FitEnsemble[_doc.FitEnsemble.Count - 1].FitFunction == null)
            {
                _doc.FitEnsemble[_doc.FitEnsemble.Count - 1].FitFunction = func;
                _doc.SetDefaultParametersForFitElement(_doc.FitEnsemble.Count - 1);
                changed = true;
            }
            else // Count>0, and there is already a fit function, we
            { // have to ask the user whether he wants to discard the old functions or keep them
                System.Enum selchoice = _lastSelectionChoice;
                if (Current.Gui.ShowDialog(ref selchoice, "As only or as additional?"))
                {
                    _lastSelectionChoice = (SelectionChoice)selchoice;
                    if (_lastSelectionChoice == SelectionChoice.SelectAsAdditional)
                    {
                        FitElement newele = new FitElement();
                        newele.FitFunction = func;
                        _doc.FitEnsemble.Add(newele);
                        _doc.SetDefaultParametersForFitElement(_doc.FitEnsemble.Count - 1);
                        changed = true;
                    }
                    else // select as only
                    {
                        _doc.FitEnsemble[0].FitFunction = func;
                        _doc.SetDefaultParametersForFitElement(0);

                        for (int i = _doc.FitEnsemble.Count - 1; i >= 1; --i)
                        {
                            _doc.FitEnsemble.RemoveAt(i);
                        }

                        changed = true;
                    }
                }
            }

            if (changed)
            {
                // _doc.FitEnsemble.InitializeParameterSetFromEnsembleParameters(_doc.CurrentParameters);

                this._fitEnsembleController.Refresh();
            }
        }
示例#3
0
        public void Initialize(FitElement fitElement)
        {
            _fitElement = fitElement;

            _numberOfX         = _fitElement.NumberOfIndependentVariables;
            _numberOfY         = _fitElement.NumberOfDependentVariables;
            _numberOfParameter = _fitElement.NumberOfParameters;

            _totalSlots = Math.Max(_numberOfParameter, _numberOfX + _numberOfY + 1);
            _slotHeight = System.Windows.Forms.SystemInformation.MenuButtonSize.Height;
            _pen        = System.Drawing.Pens.Blue;

            this.ClientSize = new Size(this.ClientSize.Width, _totalSlots * _slotHeight);
        }
        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();
            }
        }
示例#5
0
        private void EhDeletionOfFitElementRequested(FitElement fitElement)
        {
            for (int i = _doc.Count - 1; i >= 0; --i)
            {
                if (object.ReferenceEquals(_doc[i], fitElement))
                {
                    _doc.RemoveAt(i);
                    DetachFitElementController(_fitEleController[i]);
                    _fitEleController.RemoveAt(i);
                    _fitEleControls.RemoveAt(i);
                    break;
                }
            }

            _view.Initialize(_doc, _fitEleControls);
        }
示例#6
0
 public FitElementController(FitElement doc)
 {
     _doc = doc;
 }