Exemple #1
0
 public LayerRegionViewModel(LayerTissueRegion region, string name)
 {
     _region            = region;
     _name              = name ?? "";
     _zRangeVM          = new RangeViewModel(_region.ZRange, "mm", IndependentVariableAxis.Z, "", false);
     _opticalPropertyVM = new OpticalPropertyViewModel(_region.RegionOP, "mm-1", "", true, true, true, true);
     _opticalPropertyVM.PropertyChanged += (s, a) => OnPropertyChanged("Name");
 }
Exemple #2
0
        public FluenceSolverViewModel()
        {
            RhoRangeVM = new RangeViewModel(new DoubleRange(0.1, 19.9, 300), "mm", IndependentVariableAxis.Rho, "");
            ZRangeVM   = new RangeViewModel(new DoubleRange(0.1, 19.9, 300), "mm", IndependentVariableAxis.Z, "");
            SourceDetectorSeparation = 10.0;
            TimeModulationFrequency  = 0.1;
            _tissueInputVM           = new OpticalPropertyViewModel();

            // 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("Fluence Solution Domain", FluenceSolutionDomainType.FluenceOfRhoAndZ);
            FluenceSolutionDomainTypeOptionVM.IsFluenceOfRhoAndZAndTimeEnabled = false;
            FluenceSolutionDomainTypeOptionVM.IsFluenceOfRhoAndZAndFtEnabled   = true;
            AbsorbedEnergySolutionDomainTypeOptionVM = new FluenceSolutionDomainOptionViewModel("Absorbed Energy Solution Domain", FluenceSolutionDomainType.FluenceOfRhoAndZ);
            AbsorbedEnergySolutionDomainTypeOptionVM.IsFluenceOfRhoAndZAndTimeEnabled = false;
            AbsorbedEnergySolutionDomainTypeOptionVM.IsFluenceOfRhoAndZAndFtEnabled   = true;
            PhotonHittingDensitySolutionDomainTypeOptionVM = new FluenceSolutionDomainOptionViewModel("PHD Solution Domain", 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?
                this.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));
        }
        public SpectralMappingViewModel()
        {
#if WHITELIST
            ScatteringTypeVM = new OptionViewModel <ScatteringType>("Scatterer Type", true, WhiteList.ScatteringTypes);
#else
            ScatteringTypeVM = new OptionViewModel <ScatteringType>("Scatterer Type", true);
#endif
            ScatteringTypeVM.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "SelectedValue" && SelectedTissue != null)//SelectedTissue.ScattererType != ScatteringTypeVM.SelectedValue)
                {
                    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)
                    {
                        PowerLawScatterer myScatterer = (PowerLawScatterer)SelectedTissue.Scatterer;
                        myScatterer.SetTissueType(SelectedTissue.TissueType);
                    }
                    ScatteringTypeName = SelectedTissue.Scatterer.GetType().FullName;
                }
                OnPropertyChanged("Scatterer");
                UpdateOpticalProperties();
            };

            WavelengthRangeVM = new RangeViewModel(new DoubleRange(650.0, 1000.0, 36), "nm", IndependentVariableAxis.Wavelength, "Wavelength Range");

            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;

            PlotMuaSpectrumCommand  = new RelayCommand(PlotMuaSpectrum_Executed);
            PlotMuspSpectrumCommand = new RelayCommand(PlotMuspSpectrum_Executed);

            Commands.SD_SetWavelength.Executed += (snder, args) => // updates when solution domain is involved in spectral feedback
            {
                // Wavelength = (double) args.Parameter; // this will ping-pong back to FS (stack overflow), so repeating setter logic here:
                _wavelength = (double)args.Parameter;
                UpdateOpticalProperties();
                // Commands.Spec_UpdateWavelength.Execute(_wavelength); (don't do this)

                this.OnPropertyChanged("Wavelength");
            };
        }