Exemplo n.º 1
0
 public LayerRegionViewModel(LayerTissueRegion region, string name)
 {
     _region            = region;
     _name              = name ?? "";
     _zRangeVM          = new RangeViewModel(_region.ZRange, StringLookup.GetLocalizedString("Measurement_mm"), IndependentVariableAxis.Z, "", false);
     _opticalPropertyVM = new OpticalPropertyViewModel(_region.RegionOP, StringLookup.GetLocalizedString("Measurement_Inv_mm"), "", true, true, true, true);
     _opticalPropertyVM.PropertyChanged += (s, a) => OnPropertyChanged("Name");
 }
Exemplo n.º 2
0
        public FluenceSolverViewModel()
        {
            RhoRangeVM = new RangeViewModel(new DoubleRange(0.1, 19.9, 100), StringLookup.GetLocalizedString("Measurement_mm"), IndependentVariableAxis.Rho, "");
            ZRangeVM   = new RangeViewModel(new DoubleRange(0.1, 19.9, 100), StringLookup.GetLocalizedString("Measurement_mm"), IndependentVariableAxis.Z, "");
            SourceDetectorSeparation = 10.0;
            TimeModulationFrequency  = 0.1;
            _tissueInputVM           = new OpticalPropertyViewModel(new OpticalProperties(),
                                                                    IndependentVariableAxisUnits.InverseMM.GetInternationalizedString(),
                                                                    StringLookup.GetLocalizedString("Heading_OpticalProperties"));

            // right now, we're doing manual databinding to the selected item. need to enable databinding
            // confused, though - do we need to use strings? or, how to make generics work with dependency properties?
            ForwardSolverTypeOptionVM = new OptionViewModel <ForwardSolverType>(
                "Forward Model",
                false,
                new[]
            {
                ForwardSolverType.DistributedPointSourceSDA,
                ForwardSolverType.PointSourceSDA,
                ForwardSolverType.DistributedGaussianSourceSDA,
                ForwardSolverType.TwoLayerSDA
            });     // explicitly enabling these for the workshop

            FluenceSolutionDomainTypeOptionVM = new FluenceSolutionDomainOptionViewModel(StringLookup.GetLocalizedString("Heading_FluenceSolutionDomain"),
                                                                                         FluenceSolutionDomainType.FluenceOfRhoAndZ);
            FluenceSolutionDomainTypeOptionVM.IsFluenceOfRhoAndZAndTimeEnabled = false;
            FluenceSolutionDomainTypeOptionVM.IsFluenceOfRhoAndZAndFtEnabled   = true;
            AbsorbedEnergySolutionDomainTypeOptionVM =
                new FluenceSolutionDomainOptionViewModel(StringLookup.GetLocalizedString("Heading_AbsorbedEnergySolutionDomain"),
                                                         FluenceSolutionDomainType.FluenceOfRhoAndZ);
            AbsorbedEnergySolutionDomainTypeOptionVM.IsFluenceOfRhoAndZAndTimeEnabled = false;
            AbsorbedEnergySolutionDomainTypeOptionVM.IsFluenceOfRhoAndZAndFtEnabled   = true;
            PhotonHittingDensitySolutionDomainTypeOptionVM =
                new FluenceSolutionDomainOptionViewModel(StringLookup.GetLocalizedString("Heading_PHDSolutionDomain"),
                                                         FluenceSolutionDomainType.FluenceOfRhoAndZ);
            PhotonHittingDensitySolutionDomainTypeOptionVM.IsFluenceOfRhoAndZAndTimeEnabled = false;
            PhotonHittingDensitySolutionDomainTypeOptionVM.IsFluenceOfRhoAndZAndFtEnabled   = true;
            PropertyChangedEventHandler updateSolutionDomain = (sender, args) =>
            {
                if (args.PropertyName == "IndependentAxisType")
                {
                    RhoRangeVM = ((FluenceSolutionDomainOptionViewModel)sender).IndependentAxesVMs[0].AxisRangeVM;
                }
                // todo: must this fire on ANY property, or is there a specific one we can listen to, as above?
                OnPropertyChanged("IsTimeFrequencyDomain");
            };

            FluenceSolutionDomainTypeOptionVM.PropertyChanged              += updateSolutionDomain;
            AbsorbedEnergySolutionDomainTypeOptionVM.PropertyChanged       += updateSolutionDomain;
            PhotonHittingDensitySolutionDomainTypeOptionVM.PropertyChanged += updateSolutionDomain;

            MapTypeOptionVM = new OptionViewModel <MapType>(
                "Map Type",
                new[]
            {
                MapType.Fluence,
                MapType.AbsorbedEnergy,
                MapType.PhotonHittingDensity
            });

            MapTypeOptionVM.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "SelectedValues")
                {
                    OnPropertyChanged("IsFluence");
                    OnPropertyChanged("IsAbsorbedEnergy");
                    OnPropertyChanged("IsPhotonHittingDensity");
                    OnPropertyChanged("IsTimeFrequencyDomain");
                    UpdateAvailableOptions();
                }
            };

            ForwardSolverTypeOptionVM.PropertyChanged += (sender, args) =>
            {
                OnPropertyChanged("ForwardSolver");
                OnPropertyChanged("IsGaussianForwardModel");
                OnPropertyChanged("IsMultiRegion");
                OnPropertyChanged("IsSemiInfinite");
                TissueInputVM = GetTissueInputVM(IsMultiRegion ? "MultiLayer" : "SemiInfinite");
                UpdateAvailableOptions();
                OnPropertyChanged("IsTimeFrequencyDomain");
            };

            ExecuteFluenceSolverCommand = new RelayCommand(() => ExecuteFluenceSolver_Executed(null, null));
            CancelFluenceSolverCommand  = new RelayCommand(() => CancelFluenceSolver_Executed(null, null));
            _canRunSolver    = true;
            _canCancelSolver = false;
        }
        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)
                {
                    SelectedTissue.Scatterer = SolverFactory.GetScattererType(ScatteringTypeVM.SelectedValue);
                    if (SelectedTissue.Scatterer is INotifyPropertyChanged bindableScatterer)
                    {
                        bindableScatterer.PropertyChanged += (s, a) => UpdateOpticalProperties();
                    }
                    ScatteringTypeName = SelectedTissue.Scatterer.GetType().FullName;
                    // Set the tissue type again for skin so it will set the PowerLaw A and B values correctly
                    if (SelectedTissue.ScattererType == ScatteringType.PowerLaw && SelectedTissue.TissueType != TissueType.IntralipidPhantom)
                    {
                        var myScatterer = (PowerLawScatterer)SelectedTissue.Scatterer;
                        myScatterer.SetTissueType(SelectedTissue.TissueType);
                    }
                }
                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.Scatterer.GetType().FullName;

            OpticalProperties = new OpticalProperties(0.01, 1, 0.8, 1.4);
            Wavelength        = 650;

            ResetConcentrations     = new RelayCommand <object>(ResetConcentrations_Executed);
            UpdateWavelength        = new RelayCommand <object>(UpdateWavelength_Executed);
            PlotMuaSpectrumCommand  = new RelayCommand(PlotMuaSpectrum_Executed);
            PlotMuspSpectrumCommand = new RelayCommand(PlotMuspSpectrum_Executed);
        }