Esempio n. 1
0
        /// <summary>
        /// Draws a BSpline curve from parent branch to new branch
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="allBranches"></param>
        public void DrawOriginCurve(Canvas canvas, List <BioBranch> allBranches)
        {
            OriginCurve = new Path();

            System.Windows.Point outNode = allBranches[ParentBranchIndex].Twigs[ParentTwigIndex].HistoryNodeOUT;
            System.Windows.Point inNode  = this.Twigs[0].HistoryNodeIN;

            int offset = (int)((inNode.X - outNode.X) / 2);

            // Add a random factor to separate lines.
            int randomY = Friends.GetRandomInt(0, 32);

            System.Windows.Point P1 = new System.Windows.Point(outNode.X, outNode.Y + randomY);
            System.Windows.Point P2 = new System.Windows.Point(outNode.X + offset, outNode.Y + randomY);
            System.Windows.Point P3 = new System.Windows.Point(inNode.X - offset, inNode.Y + randomY);
            System.Windows.Point P4 = new System.Windows.Point(inNode.X, inNode.Y + randomY);

            OriginCurve.Data            = Friends.MakeBezierGeometry(P1, P2, P3, P4);
            OriginCurve.Stroke          = Brushes.LightGray;
            OriginCurve.StrokeThickness = 0.6;
            //Canvas.SetLeft(OriginCurve, 0);
            //Canvas.SetTop(OriginCurve, 0);
            Canvas.SetZIndex(OriginCurve, -1);
            canvas.Children.Add(OriginCurve);
        }
Esempio n. 2
0
        /// <summary>
        /// Draws a BSpline curve from parent branch to new branch
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="allBranches"></param>
        public void DrawOriginCurve(Canvas canvas, List <BioBranch> allBranches)
        {
            OriginCurve = new Path();

            System.Windows.Point outNode = allBranches[ParentBranchIndex].Twigs[ParentTwigIndex].HistoryNodeOUT;
            System.Windows.Point inNode  = this.Twigs[0].HistoryNodeIN;

            int offset = (int)((inNode.X - outNode.X) / 2);

            // Add a random factor to separate lines.
            int randomY = Friends.GetRandomInt(0, 32);

            System.Windows.Point P1 = new System.Windows.Point(outNode.X, outNode.Y + randomY);
            System.Windows.Point P2 = new System.Windows.Point(outNode.X + offset, outNode.Y + randomY);
            System.Windows.Point P3 = new System.Windows.Point(inNode.X - offset, inNode.Y + randomY);
            System.Windows.Point P4 = new System.Windows.Point(inNode.X, inNode.Y + randomY);

            OriginCurve.Data            = Friends.MakeBezierGeometry(P1, P2, P3, P4);
            OriginCurve.Stroke          = Brushes.White;
            OriginCurve.StrokeThickness = 0.6;
            //Canvas.SetLeft(OriginCurve, 0);
            //Canvas.SetTop(OriginCurve, 0);
            Canvas.SetZIndex(OriginCurve, -1);
            canvas.Children.Add(OriginCurve);


            //Add outline circle
            double s = 6;

            System.Windows.Shapes.Ellipse nodule = new System.Windows.Shapes.Ellipse();
            nodule.Height = s;
            nodule.Width  = s;
            nodule.Fill   = Brushes.White;
            System.Windows.Shapes.Ellipse nodule2 = new System.Windows.Shapes.Ellipse();
            nodule2.Height = s;
            nodule2.Width  = s;
            nodule2.Fill   = Brushes.White;

            Canvas.SetLeft(nodule, P1.X - s / 2);
            Canvas.SetTop(nodule, P1.Y - s / 2);
            canvas.Children.Add(nodule);

            Canvas.SetLeft(nodule2, P4.X - s / 2);
            Canvas.SetTop(nodule2, P4.Y - s / 2);
            canvas.Children.Add(nodule2);
        }