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; } }
public void BuildAncTree() { fSegments.Clear(); const float startRad = CircleChartModel.CENTER_RAD - 50; float inRad = startRad; AncPersonSegment segment = new AncPersonSegment(0); segment.IntRad = 0; segment.ExtRad = inRad; segment.StartAngle = 0 - 90.0f; segment.WedgeAngle = segment.StartAngle + 360.0f; IGfxPath path = segment.Path; path.StartFigure(); path.AddEllipse(-inRad, -inRad, inRad * 2.0f, inRad * 2.0f); path.CloseFigure(); fSegments.Add(segment); int maxSteps = 1; for (int gen = 1; gen <= fMaxGenerations; gen++) { inRad = startRad + ((gen - 1) * fGenWidth); float extRad = inRad + fGenWidth; maxSteps *= 2; float stepAngle = (360.0f / maxSteps); for (int step = 0; step < maxSteps; step++) { float ang1 = (step * stepAngle) - 90.0f; float ang2 = ang1 + stepAngle; segment = new AncPersonSegment(gen); segment.StartAngle = ang1; segment.WedgeAngle = stepAngle; fRenderer.CreateCircleSegment(segment.Path, inRad, extRad, stepAngle, ang1, ang2); fSegments.Add(segment); } } // traverse tree fGroupCount = -1; fIndividualsCount = 0; if (fRootPerson == null) { return; } fIndividualsCount++; AncPersonSegment rootSegment = SetSegmentParams(0, fRootPerson, 0, -1); if (rootSegment == null) { return; } rootSegment.WedgeAngle = 360.0f; GEDCOMIndividualRecord father = null, mother = null; GEDCOMFamilyRecord fam = fRootPerson.GetParentsFamily(); if (fam != null && fBase.Context.IsRecordAccess(fam.Restriction)) { father = fam.GetHusband(); mother = fam.GetWife(); } if (mother != null) { rootSegment.MotherSegment = TraverseAncestors(mother, 90f, 1, CircleChartModel.CENTER_RAD, 90.0f, 1, -1); } if (father != null) { rootSegment.FatherSegment = TraverseAncestors(father, 270.0f, 1, CircleChartModel.CENTER_RAD, 90.0f, 1, -1); } }