Commit c32ec4cb authored by Francesco Carraro's avatar Francesco Carraro
Browse files

fixes to loading of xml file containing continuum-removed spectrum

parent 1d08218e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
using INAF.Apps.Uwp.SLabDataManager.Models.Chart.Fit;
using System.Collections.Generic;
using System.Linq;

namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI.Chart
{
@@ -20,6 +21,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI.Chart
            FitMethods.Add(fitMethod);
        }

        public FitMethodModel getFitMethod(string fitMethodName)
        {
            return FitMethods.FirstOrDefault(x => x.MethodName.Equals(fitMethodName));
        }

        public List<FitMethodModel> getFitMethods()
        {
            List<FitMethodModel> clonedMethods = new List<FitMethodModel>(FitMethods.Count);
+14 −1
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models.Chart.Fit
{
    public sealed class SegmentFitModel : ObservableObject
    {
        /* ctor used when spectrum need to be processed from aligned one */
        public SegmentFitModel(PointModel p1,
                               PointModel p2,
                               List<FitMethodModel> fitMethods)
@@ -22,12 +23,15 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models.Chart.Fit

            IsShown = false;

            /* this deny the creation of numericbox for parmeterValue when combobox is created.
             * This because the default selected fit method, linear, doesn't need this elements */
            IsSelectedFitMethodChangedEventAllowed = false;

            if (FitMethods?.Count > 0)
                selectedFitMethod = FitMethods[0];
        }

        /* this ctor is used when we're loading processed xml files */
        public SegmentFitModel(PointModel p1,
                               PointModel p2,
                               string fitMethodName,
@@ -37,8 +41,12 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models.Chart.Fit
            if (FitMethods?.Count > 0)
            {
                SelectedFitMethod = FitMethods.FirstOrDefault(x => x.MethodName.Equals(fitMethodName));
                if (SelectedFitMethod != null)
                if (SelectedFitMethod != null && SelectedFitMethod.ParameterConstraintValue != null)
                    SelectedFitMethod.ParameterConstraintValue.Value = paramValue;

                /* this overwrite of variable value, allows creation of numericbox, because we're loading values from
                 * processed filex and the selected fit method is different from the linear one, and this element is required */
                IsSelectedFitMethodChangedEventAllowed = true;
            }
        }

@@ -85,6 +93,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models.Chart.Fit
        }
        #endregion

        public void raiseSelectedFitMethod()
        {
            OnPropertyChanged(nameof(SelectedFitMethod));
        }

        private void setRangeText()
        {
            RangeText = "SegmentsFitRangeLabel".GetText()
+8 −0
Original line number Diff line number Diff line
@@ -17,5 +17,13 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models.Chart.Fit
        {
            return new SegmentFitModel(p1, p2, fitMethodsContainer.getFitMethods());
        }

        public SegmentFitModel createSegmentFitModel(PointModel p1,
                                                     PointModel p2,
                                                     string fitMethodName,
                                                     double paramValue)
        {
            return new SegmentFitModel(p1, p2, fitMethodName, paramValue, fitMethodsContainer.getFitMethods());
        }
    }
}
+12 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
using INAF.Apps.Uwp.SLabDataManager.Models.Chart;
using System.Collections.ObjectModel;
using System.Linq;
using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums;

namespace INAF.Apps.Uwp.SLabDataManager.Models.Containers
{
@@ -58,9 +59,19 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models.Containers
            ChartSpectraModels.Clear();
        }

        public void delete(SpectrumType spectrumType)
        {
            if (!ChartSpectraModels.Any(x => x.Type == spectrumType))
                return;

            var item = ChartSpectraModels.FirstOrDefault(x => x.Type == spectrumType);
            if (item != null)
                ChartSpectraModels.Remove(item);
        }

        public T get<T>() where T : IChartSpectrumModel
        {
            return (T)ChartSpectraModels.First(x => x is T);
            return (T)ChartSpectraModels.FirstOrDefault(x => x is T);
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -614,10 +614,12 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels
            {
                case AlignmentUserControl alignmentUserControl:
                    manageSpectrumOfTypeAligned(processedSpectraContainer);
                    processedSpectraContainer.delete(SpectrumType.Aligned);
                    break;

                case SegmentsFitUserControl segmentsFitUserControl:
                    manageSpectrumOfTypeContinuumRemoved(processedSpectraContainer);
                    processedSpectraContainer.delete(SpectrumType.ContinuumRemoved);
                    break;

                default:
Loading