private void UpdateOpticalProperties() { OpticalProperties = SelectedTissue.GetOpticalProperties(Wavelength); this.OnPropertyChanged("Mua"); this.OnPropertyChanged("Musp"); this.OnPropertyChanged("G"); this.OnPropertyChanged("N"); this.OnPropertyChanged("OpticalProperties"); Commands.Spec_UpdateOpticalProperties.Execute(OpticalProperties); }
private void UpdateOpticalProperties() { OpticalProperties = SelectedTissue.GetOpticalProperties(Wavelength); OnPropertyChanged("Mua"); OnPropertyChanged("Musp"); OnPropertyChanged("G"); OnPropertyChanged("N"); OnPropertyChanged("OpticalProperties"); WindowViewModel.Current.ForwardSolverVM.UpdateOpticalProperties_Executed(); }
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"); }; }