Ejemplo n.º 1
0
        private SSBasePairViewModel BuildBasePairViewModel(XRNABasePair bp)
        {
            SSSymbolViewModel fivePrimeNtVM  = BuildSymbolViewModel(bp.FivePrimeNucleotide);
            SSSymbolViewModel threePrimeNtVM = BuildSymbolViewModel(bp.ThreePrimeNucleotide);

            return(new SSBasePairViewModel(fivePrimeNtVM, threePrimeNtVM));
        }
Ejemplo n.º 2
0
        private SSSymbolViewModel BuildSymbolViewModel(XRNANucleotide symbol)
        {
            SSSymbolViewModel retValue = new SSSymbolViewModel(symbol.Sequence.RawData[symbol.Index], symbol.Index + 1,
                                                               new FontFamily(symbol.FontFace), (FontStyle)_fscvtr.ConvertFrom(symbol.FontStyle), (FontWeight)_fwcvtr.ConvertFrom(symbol.FontWeight), (Brush)_colorCvtr.ConvertFrom(symbol.Color),
                                                               symbol.FontSize, symbol.Center.X, symbol.Center.Y);

            retValue.Visible = !symbol.Hidden;
            return(retValue);
        }
Ejemplo n.º 3
0
 public SSBasePairViewModel(SSSymbolViewModel fivePrimeNt, SSSymbolViewModel threePrimeNt)
 {
     Debug.Assert(fivePrimeNt != null);
     Debug.Assert(threePrimeNt != null);
     FivePrimeNucleotide  = fivePrimeNt;
     ThreePrimeNucleotide = threePrimeNt;
     X      = Math.Min(FivePrimeNucleotide.X, ThreePrimeNucleotide.X);
     Y      = Math.Min(FivePrimeNucleotide.Y, ThreePrimeNucleotide.Y);
     Width  = Math.Max(FivePrimeNucleotide.X, ThreePrimeNucleotide.X) - X + FivePrimeNucleotide.Width;
     Height = Math.Max(FivePrimeNucleotide.Y, ThreePrimeNucleotide.Y) - Y + FivePrimeNucleotide.Height;
 }
Ejemplo n.º 4
0
        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);
        }