Пример #1
0
        public PlotViewModel(int plotViewId = 0)
        {
            _plotViewId   = plotViewId;
            _minYValue    = MinY = 1E-9;
            _maxYValue    = MaxY = 1.0;
            _minXValue    = MinX = 1E-9;
            _maxXValue    = MaxX = 1.0;
            _manualScaleX = false;
            _manualScaleY = false;

            RealLabels      = new List <string>();
            ImagLabels      = new List <string>();
            PhaseLabels     = new List <string>();
            AmplitudeLabels = new List <string>();

            Labels               = new List <string>();
            PlotTitles           = new List <string>();
            DataSeriesCollection = new List <DataPointCollection>();
            PlotSeriesCollection = new PlotPointCollection();
            _IsComplexPlot       = false;

            PlotModel = new ViewResolvingPlotModel
            {
                Title           = "",
                LegendPlacement = LegendPlacement.Outside,
                DefaultColors   = new List <OxyColor>
                {
                    OxyColor.FromRgb(0x00, 0x80, 0x00),     // Green
                    OxyColor.FromRgb(0xD6, 0x89, 0x10),     // Dark Orange
                    OxyColor.FromRgb(0xDC, 0x14, 0x3C),     // Crimson Red
                    OxyColor.FromRgb(0x00, 0x00, 0xFF),     // Blue
                    OxyColor.FromRgb(0xC4, 0x15, 0xC4),     // Dark Magenta
                    OxyColor.FromRgb(0x00, 0xBF, 0xBF),     // Turquoise
                    OxyColor.FromRgb(0x4F, 0x4F, 0x4F),     // Dark Grey
                    OxyColor.FromRgb(0x33, 0x99, 0xFF),     // Light Blue
                    OxyColor.FromRgb(0x80, 0x00, 0x00),     // Maroon
                    OxyColor.FromRgb(0x00, 0x80, 0x80),     // Teal
                    OxyColor.FromRgb(0x00, 0x00, 0x80),     // Navy Blue
                    OxyColor.FromRgb(0x99, 0x99, 0x00),     // Olive Green
                }
            };
            PlotType               = ReflectancePlotType.ForwardSolver;
            _HoldOn                = true;
            _HideKey               = false;
            _ShowInPlotView        = true;
            _ShowAxes              = false;
            _showComplexPlotToggle = false;
            _xAxisLog10            = false;
            _yAxisLog10            = false;

            PlotToggleTypeOptionVM = new OptionViewModel <PlotToggleType>("ToggleType_" + _plotViewId, false);
            PlotToggleTypeOptionVM.PropertyChanged += (sender, args) => UpdatePlotSeries();

            PlotNormalizationTypeOptionVM =
                new OptionViewModel <PlotNormalizationType>("NormalizationType_" + _plotViewId, false);
            PlotNormalizationTypeOptionVM.PropertyChanged += (sender, args) => UpdatePlotSeries();

            //Commands.Plot_PlotValues.Executed += Plot_Executed;
            //Commands.Plot_SetAxesLabels.Executed += Plot_SetAxesLabels_Executed;


            //PlotValues = new RelayCommand<Array>(Plot_Executed);
            PlotValuesCommand = new Command <Array>(async(x) => await ExecutePlotCommand(x));
            //SetAxesLabels = new RelayCommand<object>(Plot_SetAxesLabels_Executed);
            //ClearPlotCommand = new RelayCommand(() => Plot_Cleared(null, null));
            ClearPlotCommand       = new Command(async() => await Plot_Cleared());
            ClearPlotSingleCommand = new Command(async() => await Plot_ClearedSingle());
            //ClearPlotSingleCommand = new RelayCommand(() => Plot_ClearedSingle(null, null));
            //ExportDataToTextCommand = new RelayCommand(() => Plot_ExportDataToText_Executed(null, null));
            //DuplicateWindowCommand = new RelayCommand(() => Plot_DuplicateWindow_Executed(null, null));
        }
Пример #2
0
        public SpectralMappingViewModel()
        {
#if WHITELIST
            ScatteringTypeVM = new OptionViewModel <ScatteringType>(StringLookup.GetLocalizedString("Heading_ScattererType"), true, WhiteList.ScatteringTypes);
#else
            ScatteringTypeVM = new OptionViewModel <ScatteringType>(StringLookup.GetLocalizedString("Heading_ScattererType"), true);
#endif
            ScatteringTypeVM.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "SelectedValue" && SelectedTissue != null) // this runs based on Tissue changes
                {
                    //SelectedTissue.Scatterer = SolverFactory.GetScattererType(ScatteringTypeVM.SelectedValue);
                    var bindableScatterer = SelectedTissue.Scatterer as INotifyPropertyChanged;
                    if (bindableScatterer != null)
                    {
                        bindableScatterer.PropertyChanged += (s, a) => UpdateOpticalProperties();
                    }
                    //LM - Temporary Fix to reset the tissue type after a new scatterer is created
                    //if (SelectedTissue.ScattererType == ScatteringType.PowerLaw)
                    //{
                    //    var myScatterer = (PowerLawScatterer)SelectedTissue.Scatterer;
                    //    myScatterer.SetTissueType(SelectedTissue.TissueType);
                    //}
                    //ScatteringTypeName = SelectedTissue.Scatterer.GetType().FullName;
                    DisplayIntralipidScatterer = ScatteringTypeVM.SelectedValue == ScatteringType.Intralipid;
                    DisplayPowerLawScatterer   = ScatteringTypeVM.SelectedValue == ScatteringType.PowerLaw;
                    DisplayMieScatterer        = ScatteringTypeVM.SelectedValue == ScatteringType.Mie;
                }

                OnPropertyChanged("Scatterer");
                UpdateOpticalProperties();
            };

            WavelengthRangeVM = new RangeViewModel(new DoubleRange(650.0, 1000.0, 36), StringLookup.GetLocalizedString("Measurement_nm"),
                                                   IndependentVariableAxis.Wavelength, StringLookup.GetLocalizedString("Heading_WavelengthRange"));

            Tissues = new List <Tissue>()
            {
                new Tissue(TissueType.Skin),
                new Tissue(TissueType.BrainWhiteMatter),
                new Tissue(TissueType.BrainGrayMatter),
                new Tissue(TissueType.BreastPreMenopause),
                new Tissue(TissueType.BreastPostMenopause),
                new Tissue(TissueType.Liver),
                new Tissue(TissueType.IntralipidPhantom),
                //new Tissue(TissueType.PolystyreneSpherePhantom),
                new Tissue(TissueType.Custom)
            };

            BloodConcentrationVM = new BloodConcentrationViewModel();

            //            #region DC notes 1

            //            // DC NOTES on how to propagate the correct hemoglobin instances into BloodConcentrationVM:
            //            // Upon setting SelectedTissue (below), we internally update the BloodConcentrationVM hemoglobin references
            //            // This is the simplest solution, but maybe violates SOC...(see SelectedTissue property for details)
            //            // A second alternative way would be to override AfterPropertyChanged (see AfterPropertyChanged method below)

            //            #endregion

            BloodConcentrationVM.PropertyChanged += (sender, args) => UpdateOpticalProperties();

            SelectedTissue = Tissues.First();
            ScatteringTypeVM.SelectedValue = SelectedTissue.ScattererType;
            // forces update to all bindings established in hanlder for ScatteringTypeVM.PropertyChanged above
            //ScatteringTypeName = SelectedTissue.GetType().FullName;
            OpticalProperties          = new OpticalProperties(0.01, 1, 0.8, 1.4);
            Wavelength                 = 650;
            CustomPlotLabel            = "";
            ResetConcentrationsCommand = new Command <object>(OnResetConcentrationsCommand);
            //UpdateWavelengthCommand = new Command(OnUpdateWavelengthCommand);
            PlotMuaSpectrumCommand  = new Command(async() => await OnPlotMuaSpectrumCommand());
            PlotMuspSpectrumCommand = new Command(async() => await OnPlotMuspSpectrumCommand());
        }