public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
      {
        

        int independentVariable = info.GetInt32("IndependentVariable");
        int dependentVariable = info.GetInt32("DependentVariable");
        double[] parameter;
        info.GetArray("ParameterValues",out parameter);

        object fo = info.GetValue("FitFunction");

        if( fo is Altaxo.Serialization.Xml.AssemblyAndTypeSurrogate)
          fo = ((Altaxo.Serialization.Xml.AssemblyAndTypeSurrogate)fo).CreateInstance();

        FitFunctionToScalarFunctionDDWrapper s;
        if(o == null)
        {
          s = new FitFunctionToScalarFunctionDDWrapper(fo as IFitFunction,dependentVariable,independentVariable,parameter);
        }
        else
        {
          s = (FitFunctionToScalarFunctionDDWrapper)o;
          s = (FitFunctionToScalarFunctionDDWrapper)o; 
          s._independentVariable = independentVariable;
          s._dependentVariable = dependentVariable;
          s._parameter = parameter;
          s._fitFunction = fo as IFitFunction;
        }

        return s;
      }
예제 #2
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                int independentVariable = info.GetInt32("IndependentVariable");
                int dependentVariable   = info.GetInt32("DependentVariable");

                double[] parameter;
                info.GetArray("ParameterValues", out parameter);

                object fo = info.GetValue("FitFunction");

                if (fo is Altaxo.Serialization.Xml.AssemblyAndTypeSurrogate)
                {
                    fo = ((Altaxo.Serialization.Xml.AssemblyAndTypeSurrogate)fo).CreateInstance();
                }

                FitFunctionToScalarFunctionDDWrapper s;

                if (o == null)
                {
                    s = new FitFunctionToScalarFunctionDDWrapper(fo as IFitFunction, dependentVariable, independentVariable, parameter);
                }
                else
                {
                    s = (FitFunctionToScalarFunctionDDWrapper)o;
                    s = (FitFunctionToScalarFunctionDDWrapper)o;
                    s._independentVariable = independentVariable;
                    s._dependentVariable   = dependentVariable;
                    s._parameter           = parameter;
                    s._fitFunction         = fo as IFitFunction;
                }

                return(s);
            }
예제 #3
0
            public void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                FitFunctionToScalarFunctionDDWrapper s = (FitFunctionToScalarFunctionDDWrapper)obj;

                info.AddValue("IndependentVariable", s._independentVariable);
                info.AddValue("DependentVariable", s._dependentVariable);
                info.AddArray("ParameterValues", s._parameter, s._parameter.Length);

                if (s._fitFunction == null || info.IsSerializable(s._fitFunction))
                {
                    info.AddValue("FitFunction", s._fitFunction);
                }
                else
                {
                    info.AddValue("FitFunction", new Altaxo.Serialization.Xml.AssemblyAndTypeSurrogate(s._fitFunction));
                }
            }
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                int independentVariable = info.GetInt32("IndependentVariable");
                var independentVariableTransformation = (IVariantToVariantTransformation)info.GetValue("IndependentVariableTransformation", null);
                int dependentVariable = info.GetInt32("DependentVariable");
                var dependentVariableTransformation = (IVariantToVariantTransformation)info.GetValue("DependentVariableTransformation", null);

                info.GetArray("ParameterValues", out double[] parameter);

                object fo = info.GetValue("FitFunction", null);

                if (fo is Altaxo.Serialization.Xml.AssemblyAndTypeSurrogate)
                {
                    fo = ((Altaxo.Serialization.Xml.AssemblyAndTypeSurrogate)fo).CreateInstance();
                }

                FitFunctionToScalarFunctionDDWrapper s;

                if (o == null)
                {
                    s = new FitFunctionToScalarFunctionDDWrapper(fo as IFitFunction, dependentVariable, dependentVariableTransformation, independentVariable, independentVariableTransformation, parameter);
                }
                else
                {
                    s = (FitFunctionToScalarFunctionDDWrapper)o;
                    s._independentVariable = independentVariable;
                    s._independentVariableTransformation = independentVariableTransformation;
                    s._dependentVariable = dependentVariable;
                    s._dependentVariableTransformation = dependentVariableTransformation;
                    s._parameter   = parameter;
                    s._fitFunction = fo as IFitFunction;

                    if (s._fitFunction is Main.IDocumentLeafNode && !(s._fitFunction is Altaxo.Scripting.FitFunctionScript))
                    {
                        ((Main.IDocumentLeafNode)s._fitFunction).ParentObject = s;
                    }
                }

                return(s);
            }
    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();
      }
    }