Пример #1
0
        private void CalcDescendants(DescPersonSegment segment, float inRad, float startAngle, float stepAngle)
        {
            IGfxPath path = segment.Path;

            float extRad;

            if (segment.Gen == 0)
            {
                segment.StartAngle = startAngle;
                segment.WedgeAngle = 360.0f;
                segment.IntRad     = 0;
                segment.ExtRad     = inRad;

                path.StartFigure();
                path.AddEllipse(-inRad, -inRad, inRad * 2.0f, inRad * 2.0f);
                path.CloseFigure();

                extRad = inRad;
            }
            else
            {
                extRad = inRad + fGenWidth;

                int   size       = Math.Max(1, segment.TotalSubSegments);
                float wedgeAngle = stepAngle * size;

                // in Eto.Drawings 360 degrees for the segments
                // leads to a crash of drawing
                if (wedgeAngle == 360.0f)
                {
                    wedgeAngle -= 0.1f;
                }

                segment.StartAngle = startAngle;
                segment.WedgeAngle = wedgeAngle;
                segment.Rad        = inRad + 50;
                segment.IntRad     = inRad;
                segment.ExtRad     = extRad;

                fRenderer.CreateCircleSegment(path, inRad, extRad, wedgeAngle, startAngle, startAngle + wedgeAngle);
            }

            for (int i = 0; i < segment.ChildSegments.Count; i++)
            {
                DescPersonSegment childSegment = segment.ChildSegments[i];

                CalcDescendants(childSegment, extRad, startAngle, stepAngle);

                int steps = Math.Max(1, childSegment.TotalSubSegments);

                startAngle += stepAngle * steps;
            }
        }
Пример #2
0
        private DescPersonSegment TraverseDescendants(GEDCOMIndividualRecord iRec, int gen)
        {
            if (iRec == null)
            {
                return(null);
            }

            try
            {
                fIndividualsCount++;

                DescPersonSegment resultSegment = new DescPersonSegment(gen);
                resultSegment.IRec = iRec;
                fSegments.Add(resultSegment);

                if (gen < fVisibleGenerations)
                {
                    int numberOfFamilyLinks = iRec.SpouseToFamilyLinks.Count;
                    for (int j = 0; j < numberOfFamilyLinks; j++)
                    {
                        GEDCOMFamilyRecord family = iRec.SpouseToFamilyLinks[j].Family;
                        if (!fBase.Context.IsRecordAccess(family.Restriction))
                        {
                            continue;
                        }

                        fBase.Context.ProcessFamily(family);

                        int numberOfChildren = family.Children.Count;
                        for (int i = 0; i < numberOfChildren; i++)
                        {
                            GEDCOMIndividualRecord child        = family.Children[i].Value as GEDCOMIndividualRecord;
                            DescPersonSegment      childSegment = TraverseDescendants(child, gen + 1);

                            int size = Math.Max(1, childSegment.TotalSubSegments);
                            resultSegment.TotalSubSegments += size;

                            resultSegment.ChildSegments.Add(childSegment);
                        }
                    }
                }

                return(resultSegment);
            }
            catch
            {
                return(null);
            }
        }
Пример #3
0
        public void DrawDescendants()
        {
            int numberOfSegments = fSegments.Count;

            for (int i = 0; i < numberOfSegments; i++)
            {
                DescPersonSegment segment = (DescPersonSegment)fSegments[i];
                if (segment.IRec == null)
                {
                    continue;
                }

                int    brIndex = (segment.Gen == 0) ? CircleChartModel.CENTRAL_INDEX : segment.Gen - 1;
                IBrush brush   = (fSelected == segment) ? fDarkBrushes[brIndex] : fCircleBrushes[brIndex];

                DrawSegment(segment, fPen, brush);
            }
        }
Пример #4
0
        public void DrawDescendants()
        {
            int numberOfSegments = fSegments.Count;

            for (int i = 0; i < numberOfSegments; i++)
            {
                DescPersonSegment segment = (DescPersonSegment)fSegments[i];
                if (segment.IRec == null)
                {
                    continue;
                }

                int    brIndex = (segment.Gen == 0) ? CircleChartModel.CENTRAL_INDEX : segment.Gen - 1;
                IBrush brush   = (fSelected == segment) ? fDarkBrushes[brIndex] : fCircleBrushes[brIndex];

                IGfxPath path = segment.Path;
                fRenderer.FillPath(brush, path);
                fRenderer.DrawPath(fPen, path);
                DrawPersonName(fSegments[i]);
            }
        }
Пример #5
0
        public void BuildDescTree()
        {
            fSegments.Clear();
            fIndividualsCount = 0;
            if (fRootPerson == null)
            {
                return;
            }

            // traverse tree
            DescPersonSegment rootSegment = TraverseDescendants(fRootPerson, 0);

            if (rootSegment == null)
            {
                return;
            }

            const float inRad     = CircleChartModel.CENTER_RAD - 50;
            float       stepAngle = (360.0f / rootSegment.TotalSubSegments);

            CalcDescendants(rootSegment, inRad, -90.0f, stepAngle);
        }
Пример #6
0
        private void CalcDescendants(DescPersonSegment segment, float inRad, float startAngle, float stepAngle)
        {
            float extRad;

            if (segment.Gen == 0)
            {
                DefineSegment(segment, 0, 0, inRad, startAngle, 360.0f);

                extRad = inRad;
            }
            else
            {
                extRad = inRad + fGenWidth;

                int   size       = Math.Max(1, segment.TotalSubSegments);
                float wedgeAngle = stepAngle * size;

                // in Eto.Drawings 360 degrees for the segments
                // leads to a crash of drawing
                if (wedgeAngle == 360.0f)
                {
                    wedgeAngle -= 0.1f;
                }

                DefineSegment(segment, inRad + 50, inRad, extRad, startAngle, wedgeAngle);
            }

            for (int i = 0; i < segment.ChildSegments.Count; i++)
            {
                DescPersonSegment childSegment = segment.ChildSegments[i];

                CalcDescendants(childSegment, extRad, startAngle, stepAngle);

                int steps = Math.Max(1, childSegment.TotalSubSegments);
                startAngle += stepAngle * steps;
            }
        }