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

working on spectrum alignment

parent a2edf8c0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ namespace INAF.Apps.Uwp.SLabDataManager
            Ioc.Default.ConfigureServices(
                new ServiceCollection()
                /* singletons */
                .AddSingleton<AlignmentConfigModel>()
                .AddSingleton<SpectrumAlignmentConfigModel>()
                .AddSingleton<SpectrumChartOptionsModel>()
                .AddSingleton<Logger>(logger)
                .AddSingleton<RecentFilesHelper>()
+31 −5
Original line number Diff line number Diff line
@@ -3,16 +3,16 @@ using INAF.Libraries.NetStandard.ScienceModels;
using INAF.Libraries.NetStandard.ScienceModels.Spectra;
using INAF.Libraries.NetStandard.ScienceModels.Spectra.Serializable;
using INAF.Libraries.Uwp.Settings;
using System.Threading.Tasks;
using static INAF.Libraries.NetStandard.ScienceModels.Enums.Enums;
using INAF.Libraries.NetStandard.Extensions;

namespace INAF.Apps.Uwp.SLabDataManager.Charts
{
    public sealed class AlignmentConfigModel : ObservableModel
    public sealed class SpectrumAlignmentConfigModel : ObservableModel
    {
        private readonly SettingsHelper settingsHelper;

        public AlignmentConfigModel(SettingsHelper settingsHelper)
        public SpectrumAlignmentConfigModel(SettingsHelper settingsHelper)
        {
            this.settingsHelper = settingsHelper;

@@ -23,6 +23,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            tryReadWavelengthModel(1);
            tryReadWavelengthModel(2);
            tryReadWavelengthModel(3);

            NumOfPointsForAlignment = 3;
        }

        #region properties
@@ -33,6 +35,13 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            set { areSeparatorsVisible = value; saveAreSeparatorsVisible(value); RaisePropertyChanged(nameof(AreSeparatorsVisible)); }
        }

        private int numOfPointsForAlignment;
        public int NumOfPointsForAlignment
        {
            get { return numOfPointsForAlignment; }
            set { numOfPointsForAlignment = value; saveNumOfPointsForAlignment(value); RaisePropertyChanged(nameof(AreSeparatorsVisible)); }
        }

        private WavelengthModel separatorWavelength0;
        public WavelengthModel SeparatorWavelength0
        {
@@ -67,6 +76,10 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
        {
            settingsHelper.save(Constants.Constants.ARE_SEPARATORS_VISIBLE, areVisible.ToString());
        }
        private void saveNumOfPointsForAlignment(int numOfPoints)
        {
            settingsHelper.save(Constants.Constants.NUM_OF_POINTS_FOR_ALIGNMENT, numOfPoints.ToString());
        }

        private void saveWavelengthModel(int index, double value, double semiRange, double step, WavelengthMeasureUnit wavelengthMeasureUnit)
        {
@@ -80,7 +93,20 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            string value = settingsHelper.get(Constants.Constants.ARE_SEPARATORS_VISIBLE);
            if (!string.IsNullOrEmpty(value))
            {
                AreSeparatorsVisible = bool.Parse(value);
                AreSeparatorsVisible = value.ToBool();
                isFound = true;
            }

            return isFound;
        }
        public bool tryReadNumOfPointsForAlignment()
        {
            bool isFound = false;

            string value = settingsHelper.get(Constants.Constants.NUM_OF_POINTS_FOR_ALIGNMENT);
            if (!string.IsNullOrEmpty(value))
            {
                NumOfPointsForAlignment = value.ToIntInvariant();
                isFound = true;
            }

@@ -199,7 +225,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            return contains;
        }

        public async Task switchToMeasureUnitAsync(WavelengthMeasureUnit newMeasureUnit)
        public void switchToMeasureUnit(WavelengthMeasureUnit newMeasureUnit)
        {
            SeparatorWavelength0.switchToMeasureUnit(newMeasureUnit);
            SeparatorWavelength1.switchToMeasureUnit(newMeasureUnit);
+1 −0
Original line number Diff line number Diff line
@@ -19,5 +19,6 @@
        public static readonly string ZOOM_MODE = "zoommode";

        public static readonly string ARE_SEPARATORS_VISIBLE = "areseparatorsvisible";
        public static readonly string NUM_OF_POINTS_FOR_ALIGNMENT = "numofpointsforalignment";
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -6,11 +6,10 @@ using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using static INAF.Apps.Uwp.SLabDataManager.Constants.Enums;
using INAF.Libraries.NetStandard.Extensions;
using INAF.Apps.Uwp.SLabDataManager.Models;
using Microsoft.Toolkit.Mvvm.DependencyInjection;
using System.IO;
using System.Text;
using INAF.Libraries.NetStandard.Extensions;
using System.Collections.Generic;

namespace INAF.Apps.Uwp.SLabDataManager.Converters
@@ -28,7 +27,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters
                return "ChartTooltipLabel".GetText()
                                            .Replace("rv_1", scatterDataPoint.XValue.ToString())
                                            .Replace("rv_mu", workingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit.GetDescription())
                                            .Replace("rv_2", scatterDataPoint.YValue.ToDoubleInvariant());
                                            .Replace("rv_2", scatterDataPoint.YValue.ToString());
            }
            catch (Exception)
            {
+2 −2
Original line number Diff line number Diff line
@@ -12,12 +12,12 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.ConfigHelpers
{
    public class ConfigReader
    {
        private readonly AlignmentConfigModel alignmentConfig;
        private readonly SpectrumAlignmentConfigModel alignmentConfig;
        private readonly XmlHelper xmlHelper;
        private readonly Logger logger;

        public ConfigReader(IServiceProvider serviceProvider,
                            AlignmentConfigModel alignmentConfigModel,
                            SpectrumAlignmentConfigModel alignmentConfigModel,
                            XmlHelper xmlHelper,
                            Logger logger)
        {
Loading