public void OnLoadAllPhyloDInteractions(List <PhyloDInteractionCircleViewModel> vms) { foreach (var vm in vms) { ModelElements.Add(vm); } }
public override bool Initialize(IBioDataLoader data) { var sdloader = data as IBioDataLoader <IStructureModelBioEntity>; if (sdloader != null) { var basePairs = from bp in sdloader.Entities.OfType <IBasePairEntity>() select bp; _sequence = basePairs.First(bp => bp.Sequence != null).Sequence; //ElementSpacing = (Width - (2 * _xPadding)) / _sequence.RawData.Count; Width = (2 * _xPadding) + ElementSpacing * _sequence.RawData.Count; for (int i = 0; i < _sequence.RawData.Count; i++) { NestedElementViewModel nevm = new NestedElementViewModel(this, _sequence.RawData[i], i); _nestedVMs.Add(nevm); } _maxBPDistance = basePairs.Max(e => e.ThreePrimeIndex - e.FivePrimeIndex - 1); _minBPDistance = basePairs.Min(e => e.ThreePrimeIndex - e.FivePrimeIndex - 1); var basepairVMs = from bp in basePairs join fpVM in _nestedVMs on bp.FivePrimeIndex equals fpVM.Index join tpVM in _nestedVMs on bp.ThreePrimeIndex equals tpVM.Index select new NestedBasePairViewModel(this, fpVM, tpVM); foreach (NestedBasePairViewModel bp in basepairVMs) { ModelElements.Add(bp); } foreach (NestedElementViewModel elem in _nestedVMs) { ModelElements.Add(elem); } var tickElems = from elem in _nestedVMs where elem.Index == 1 || elem.Index % 10 == 0 select elem; foreach (NestedElementViewModel elem in tickElems) { ModelElements.Add(new NestedElementTickViewModel(this, elem)); } } return(base.Initialize(data)); }
public override bool Initialize(IBioDataLoader data) { var sdloader = data as IBioDataLoader <IStructureModelBioEntity>; if (sdloader != null) { var basePairs = from bp in sdloader.Entities.OfType <IBasePairEntity>() select bp; IBioEntity sequence = basePairs.First(bp => bp.Sequence != null).Sequence; _seqVM = new CircleSequenceViewModel(sequence); PhyloDVM = new PhyloDCircleViewModel(_seqVM); LoadPhyloDDataCommand = new DelegatingCommand(_phyloDVM.OnLoadPhyloDData); Width = _seqVM.Width; Height = _seqVM.Height; var basePairVM = from bp in basePairs select new CircleBasePairViewModel(_seqVM, bp); foreach (var vm in basePairVM) { ModelElements.Add(vm); } ModelElements.Add(_seqVM); foreach (var vm in _seqVM.Elements) { ModelElements.Add(vm); } foreach (var vm in _seqVM.TickMarks) { ModelElements.Add(vm); } foreach (var vm in _seqVM.TickLabels) { ModelElements.Add(vm); } } return(base.Initialize(data)); }
public override bool Initialize(IBioDataLoader data) { Dictionary <int, SSBasePairViewModel> basePairVMs = new Dictionary <int, SSBasePairViewModel>(); var sdloader = data as IBioDataLoader <IStructureModelBioEntity>; if (sdloader != null) { var basePairs = from bp in sdloader.Entities.OfType <XRNABasePair>() select bp; foreach (XRNABasePair bp in basePairs) { SSBasePairViewModel bpvm = BuildBasePairViewModel(bp); ModelElements.Add(bpvm); ModelElements.Add(bpvm.FivePrimeNucleotide); ModelElements.Add(bpvm.ThreePrimeNucleotide); basePairVMs.Add(bpvm.FivePrimeNucleotide.Index, bpvm); } var unpairedNt = from nt in sdloader.Entities.OfType <XRNANucleotide>() select nt; foreach (XRNANucleotide nt in unpairedNt) { SSSymbolViewModel svm = BuildSymbolViewModel(nt); ModelElements.Add(svm); } var allEntities = from entity in sdloader.Entities select entity; foreach (IStructureModelBioEntity entity in allEntities) { if (entity is XRNABasePairConnector) { XRNABasePairConnector lc = (XRNABasePairConnector)entity; ModelElements.Add(new SSBasePairLineConnectorViewModel(basePairVMs[lc.BasePair.FivePrimeIndex + 1]) { Color = lc.Color, Thickness = lc.Thickness, Visible = lc.Visible }); } else if (entity is XRNABasePairConnectorCircle) { XRNABasePairConnectorCircle cc = (XRNABasePairConnectorCircle)entity; ModelElements.Add(new SSBasePairCircleConnectorViewModel(basePairVMs[cc.BasePair.FivePrimeIndex + 1]) { Color = cc.Color, Radius = cc.Radius, Filled = cc.Filled, Thickness = cc.Thickness }); } else if (entity is TextLabel) { TextLabel lc = (TextLabel)entity; ModelElements.Add(new SSTextLabelViewModel(lc.Start.X, lc.Start.Y, lc.Text, new FontFamily(lc.FontFace), (FontStyle)_fscvtr.ConvertFrom(lc.FontStyle), (FontWeight)_fwcvtr.ConvertFrom(lc.FontWeight), lc.FontSize, (Brush)_colorCvtr.ConvertFrom(lc.Color))); } else if (entity is LineLabel) { LineLabel ll = (LineLabel)entity; ModelElements.Add(new SSLineLabelViewModel() { X = ll.Start.X, Y = ll.Start.Y, X1 = ll.End.X - ll.Start.X, Y1 = ll.End.Y - ll.Start.Y, Color = (Brush)_colorCvtr.ConvertFrom(ll.Color), Thickness = ll.LineWeight }); } else if (entity is ParallelogramLabel) { ParallelogramLabel lc = (ParallelogramLabel)entity; SSParallelogramLabelViewModel vm = new SSParallelogramLabelViewModel() { CenterX = lc.Center.X, CenterY = lc.Center.Y, Side1Length = lc.Side1Length, RotationAngle = lc.Side1Angle, Side2Length = lc.Side2Length, ParallelogramAngle = lc.Side2Angle, Color = (Brush)_colorCvtr.ConvertFrom(lc.Color), LineWeight = lc.LineWeight }; vm.ComputeParallelogram(); ModelElements.Add(vm); } else if (entity is ArcLabel) { ArcLabel ac = (ArcLabel)entity; SSArcLabelViewModel vm = new SSArcLabelViewModel() { CenterX = ac.Center.X, CenterY = ac.Center.Y, Color = (Brush)_colorCvtr.ConvertFrom(ac.Color), LineWeight = ac.LineWeight, Radius = ac.Radius, Angle1 = ac.Angle1, Angle2 = ac.Angle2, }; vm.ComputeArc(); ModelElements.Add(vm); } else if (entity is ArrowLabel) { ArrowLabel al = (ArrowLabel)entity; SSArrowLabelViewModel vm = new SSArrowLabelViewModel() { ArrowTipX = al.ArrowTip.X, ArrowTipY = al.ArrowTip.Y, LeftTipX = al.LeftTip.X, LeftTipY = al.LeftTip.Y, Color = (Brush)_colorCvtr.ConvertFrom(al.Color), LineWeight = al.LineWeight, TailLength = al.TailLength, RotationAngle = al.Angle }; vm.ComputeArrow(); ModelElements.Add(vm); } } MeasureAndArrangeCanvas(); return(base.Initialize(data)); } return(false); }