Commit 80cdb0c0 authored by Francesco Carraro's avatar Francesco Carraro
Browse files

added reading of ref white

parent 9437cf62
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,6 +5,6 @@
		<operation type="Authentication">Account/LoginForJwt</operation>
		<operation type="SaveAlignedFile">AppSpectraFilesActions/SaveAlignedSpectrum</operation>
		<operation type="SaveFileOfType">AppSpectraFilesActions/SaveSpectrumOfType</operation>
		<operation type="IsSavedOnCloud">AppSpectraFilesActions/IsSavedOnCloud</operation>
		<operation type="IsSavedOnCloud">AppSpectraFilesActions/IsSpectrumSavedOnCloud</operation>
	</operationUrls>
</remoteOperationsData>
 No newline at end of file
+9 −9
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            spectrum.PropertyChanged += Spectrum_PropertyChanged;
        }

        public INAF.Apps.Uwp.SLabDataManager.Models.Spectrum.SpectrumModel tryGetSpectrumOfType(SpectrumType spectrumType)
        public SpectrumModel tryGetSpectrumOfType(SpectrumType spectrumType)
        {
            return Spectra.FirstOrDefault(x => x.Type == spectrumType);
        }
@@ -333,7 +333,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            IsError = false;
            ErrorMessage = string.Empty;

            INAF.Apps.Uwp.SLabDataManager.Models.Spectrum.SpectrumModel aligningSpectrum = null;
            SpectrumModel aligningSpectrum = null;

            string exMsg = string.Empty;
            await Task.Run(() =>
@@ -342,11 +342,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
                {
                    aligningSpectrum = createAligningSpectrum();

                    var refSpectrum = tryGetSpectrumOfType(SpectrumType.Ref);
                    if (refSpectrum != null)
                    var refWhiteSpectrum = tryGetSpectrumOfType(SpectrumType.RefWhite);
                    if (refWhiteSpectrum != null)
                    {
                        multiplyByRef(ref aligningSpectrum,
                                      refSpectrum);
                                      refWhiteSpectrum);
                    }

                    /* retrieve the reference segment and calculate the mean values at the borders of the segment for aligning other segments */
@@ -385,7 +385,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            }
        }

        private void alignLeftSide(ref INAF.Apps.Uwp.SLabDataManager.Models.Spectrum.SpectrumModel aligningSpectrum,
        private void alignLeftSide(ref SpectrumModel aligningSpectrum,
                                   WavelengthModel refLowSeparator,
                                   double refSegmentLeftMean)
        {
@@ -408,7 +408,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            }
        }

        private void alignRightSide(ref INAF.Apps.Uwp.SLabDataManager.Models.Spectrum.SpectrumModel aligningSpectrum,
        private void alignRightSide(ref SpectrumModel aligningSpectrum,
                                    WavelengthModel refHighSeparator,
                                    double refSegmentRightMean)
        {
@@ -428,8 +428,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            }
        }

        private void multiplyByRef(ref INAF.Apps.Uwp.SLabDataManager.Models.Spectrum.SpectrumModel aligningSpectrum,
                                   INAF.Apps.Uwp.SLabDataManager.Models.Spectrum.SpectrumModel refSpectrum)
        private void multiplyByRef(ref SpectrumModel aligningSpectrum,
                                   SpectrumModel refSpectrum)
        {
            double refMaxY = refSpectrum.Elements.Max(x => x.Y);

+0 −5
Original line number Diff line number Diff line
@@ -6,11 +6,6 @@
        public static readonly string RED = "BB1717";
        public static readonly string YELLOW = "D1AB43";

        public static readonly string RAW_SPECTRUM_FILE = "rawspectrumfile";
        public static readonly string RAW_SPECTRUM_FILE_TOKEN = "rawspectrumfiletoken";
        public static readonly string REF_SPECTRUM_FILE = "refspectrumfile";
        public static readonly string REF_SPECTRUM_FILE_TOKEN = "refspectrumfiletoken";

        public static readonly string X_AXIS_MAJOR_STEP = "xaxismajorstep";
        public static readonly string WAVELENGTH_MEASURE_UNITS = "wavelengthmeasureunits";
        public static readonly string MAJOR_LINES_VISIBILITY = "majorlinesvisibility";
+24 −0
Original line number Diff line number Diff line
@@ -35,4 +35,28 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters
            throw new NotImplementedException();
        }
    }

    public sealed class SpectrumModelConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            try
            {
                string _spectrumType = (string)parameter;
                SpectrumType spectrumType = _spectrumType.ToSpectrumType();

                SpectraContainer spectraContainer = Ioc.Default.GetService<SpectraContainer>();
                return spectraContainer.tryGetSpectrumOfType(spectrumType);
            }
            catch (Exception)
            {
                return string.Empty;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
+3 −28
Original line number Diff line number Diff line
using INAF.Apps.Uwp.SLabDataManager.Charts;
using INAF.Apps.Uwp.SLabDataManager.Helpers;
using INAF.Apps.Uwp.SLabDataManager.Helpers.UI;
using INAF.Apps.Uwp.SLabDataManager.ViewModels;
using INAF.Libraries.NetStandard.ScienceModels.Extensions;
using Microsoft.Toolkit.Mvvm.DependencyInjection;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
@@ -9,37 +12,9 @@ using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using static INAF.Apps.Uwp.SLabDataManager.Constants.Enums;
using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums;
using INAF.Libraries.NetStandard.ScienceModels.Extensions;
using Microsoft.Toolkit.Mvvm.Input;
using INAF.Libraries.NetStandard.ScienceModels.Spectra;
using INAF.Apps.Uwp.SLabDataManager.ViewModels;

namespace INAF.Apps.Uwp.SLabDataManager.Converters
{
    public sealed class SpectrumModelConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            try
            {
                string _spectrumType = (string)parameter;
                SpectrumType spectrumType = _spectrumType.ToSpectrumType();

                SpectraContainer spectraContainer = Ioc.Default.GetService<SpectraContainer>();
                return spectraContainer.tryGetSpectrumOfType(spectrumType);
            }
            catch (Exception)
            {
                return string.Empty;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }

    public sealed class SpectrumSummaryFilepathConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
Loading