private static void SearchKGInt(Vertex prevNode, GEDCOMIndividualRecord iRec, KinshipsGraph graph, RelationKind relation, RelationKind inverseRelation) { if (iRec == null) { return; } Vertex currNode = graph.FindVertex(iRec.XRef); if (currNode != null) { if (prevNode != null) { graph.AddRelation(prevNode, currNode, relation, inverseRelation); } return; } else { currNode = graph.AddIndividual(iRec); if (prevNode != null) { graph.AddRelation(prevNode, currNode, relation, inverseRelation); } } if (iRec.ChildToFamilyLinks.Count > 0) { GEDCOMFamilyRecord fam = iRec.GetParentsFamily(); if (fam != null) { GEDCOMIndividualRecord father, mother; father = fam.GetHusband(); mother = fam.GetWife(); SearchKGInt(currNode, father, graph, RelationKind.rkParent, RelationKind.rkChild); SearchKGInt(currNode, mother, graph, RelationKind.rkParent, RelationKind.rkChild); } } int num = iRec.SpouseToFamilyLinks.Count; for (int i = 0; i < num; i++) { GEDCOMFamilyRecord family = iRec.SpouseToFamilyLinks[i].Family; GEDCOMIndividualRecord spouse = ((iRec.Sex == GEDCOMSex.svMale) ? family.GetWife() : family.GetHusband()); SearchKGInt(currNode, spouse, graph, RelationKind.rkSpouse, RelationKind.rkSpouse); int num2 = family.Children.Count; for (int j = 0; j < num2; j++) { GEDCOMIndividualRecord child = (GEDCOMIndividualRecord)family.Children[j].Value; SearchKGInt(currNode, child, graph, RelationKind.rkChild, RelationKind.rkParent); } } }
private static bool CheckPersonsEx(GEDCOMIndividualRecord rec1, GEDCOMIndividualRecord rec2) { GEDCOMFamilyRecord fam1 = rec1.GetParentsFamily(); GEDCOMFamilyRecord fam2 = rec2.GetParentsFamily(); return(!Equals(fam1, fam2)); }
public object gt_get_person_parents_family(object recPtr) { GEDCOMIndividualRecord rec = recPtr as GEDCOMIndividualRecord; if (rec == null) { return(null); } GEDCOMFamilyRecord fam = rec.GetParentsFamily(); return(fam); }
public void ImportNames(GEDCOMIndividualRecord iRec) { if (iRec == null) { return; } try { string childName, childPat; var parts = GKUtils.GetNameParts(iRec); childName = parts.Name; childPat = parts.Patronymic; GEDCOMSex iSex = iRec.Sex; SetNameSex(childName, iSex); GEDCOMFamilyRecord fam = iRec.GetParentsFamily(); GEDCOMIndividualRecord father = (fam == null) ? null : fam.GetHusband(); if (father != null) { string fatherNam; parts = GKUtils.GetNameParts(father); fatherNam = parts.Name; if (IsComparable(fatherNam, childPat)) { SetName(fatherNam, childPat, iSex); } } } catch (Exception ex) { Logger.LogWrite("NamesTable.ImportName(): " + ex.Message); } }
private void ExposePerson(ColumnText mct, GEDCOMIndividualRecord iRec, string iName, float colWidth) { Paragraph pg = new Paragraph(); Chunk chunk = new Chunk(iName, fBoldFont); chunk.SetLocalDestination(iRec.XRef); pg.Add(chunk); chunk = new Chunk(GKUtils.GetPedigreeLifeStr(iRec, PedigreeFormat.Compact), fTextFont); pg.Add(chunk); pg.KeepTogether = true; mct.AddElement(pg); // FIXME IImage image = fBase.Context.GetPrimaryBitmap(iRec, 0, 0, false); if (image != null) { itImage img = TreeChartPDFRenderer.ConvertImage(image); float fitWidth = colWidth * 0.5f; img.ScaleToFit(fitWidth, fitWidth); // FIXME: the moving, if the page height is insufficient for the image height //img.Alignment = Image.TEXTWRAP; img.IndentationLeft = 5f; img.SpacingBefore = 5f; img.SpacingAfter = 5f; //Paragraph imgpar = new Paragraph(new Chunk(img, 0, 0, true)); //imgpar.KeepTogether = true; mct.AddElement(img); } GEDCOMIndividualRecord father, mother; GEDCOMFamilyRecord fam = iRec.GetParentsFamily(); if (fam == null) { father = null; mother = null; } else { father = fam.GetHusband(); mother = fam.GetWife(); } if (father != null) { pg = new Paragraph(); chunk = new Chunk(GKUtils.GetNameString(father, true, false), fLinkFont); chunk.SetLocalGoto(father.XRef); pg.Add(new Chunk(LangMan.LS(LSID.LSID_Father) + ": ", fTextFont)); pg.Add(chunk); mct.AddElement(pg); } if (mother != null) { pg = new Paragraph(); chunk = new Chunk(GKUtils.GetNameString(mother, true, false), fLinkFont); chunk.SetLocalGoto(mother.XRef); pg.Add(new Chunk(LangMan.LS(LSID.LSID_Mother) + ": ", fTextFont)); pg.Add(chunk); mct.AddElement(pg); } if (IncludeEvents && iRec.Events.Count != 0) { int num = iRec.Events.Count; for (int i = 0; i < num; i++) { GEDCOMCustomEvent evt = iRec.Events[i]; if (evt.Name == "BIRT" || evt.Name == "DEAT") { continue; } string evtName = GKUtils.GetEventName(evt); string evtVal = evt.StringValue; string evtDesc = GKUtils.GetEventDesc(evt, false); string tmp = evtName + ": " + evtVal; if (evtVal != "") { tmp += ", "; } tmp += evtDesc; mct.AddElement(new Paragraph(new Chunk(tmp, fTextFont))); } } if (IncludeNotes && iRec.Notes.Count != 0) { int num = iRec.Notes.Count; for (int i = 0; i < num; i++) { GEDCOMNotes note = iRec.Notes[i]; mct.AddElement(new Paragraph(GKUtils.MergeStrings(note.Notes), fTextFont)); } } }
// TODO: rollback changes when exception! private void ParseSource() { int srcYear; if (!int.TryParse(edSourceYear.Text, out srcYear)) { ShowError(fLangMan.LS(FLS.LSID_SourceYearInvalid)); return; } string srcName = cbSource.Text; string srcPage = edPage.Text; string place = edPlace.Text; GEDCOMSourceRecord srcRec = null; if (!string.IsNullOrEmpty(srcName)) { srcRec = fBase.Context.FindSource(srcName); if (srcRec == null) { srcRec = fBase.Context.Tree.CreateSource(); srcRec.FiledByEntry = srcName; } } GEDCOMIndividualRecord iMain = null; int num = dataGridView1.Rows.Count; for (int r = 0; r < num; r++) { DataGridViewRow row = dataGridView1.Rows[r]; string lnk = (string)row.Cells[0].Value; string nm = (string)row.Cells[1].Value; string pt = (string)row.Cells[2].Value; string fm = (string)row.Cells[3].Value; string age = (string)row.Cells[4].Value; string comment = (string)row.Cells[5].Value; if (!string.IsNullOrEmpty(lnk)) { PersonLink link = GetLinkByName(lnk); GEDCOMSex sx = fBase.Context.DefineSex(nm, pt); GEDCOMIndividualRecord iRec = fBase.Context.CreatePersonEx(nm, pt, fm, sx, false); if (!string.IsNullOrEmpty(age) && SysUtils.IsDigits(age)) { int birthYear = srcYear - int.Parse(age); fBase.Context.CreateEventEx(iRec, "BIRT", "ABT " + birthYear.ToString(), ""); } if (!string.IsNullOrEmpty(place)) { GEDCOMCustomEvent evt = fBase.Context.CreateEventEx(iRec, "RESI", "", ""); evt.Place.StringValue = place; } if (!string.IsNullOrEmpty(comment)) { GEDCOMNoteRecord noteRec = fBase.Context.Tree.CreateNote(); noteRec.SetNoteText(comment); iRec.AddNote(noteRec); } if (srcRec != null) { iRec.AddSource(srcRec, srcPage, 0); } fBase.NotifyRecord(iRec, RecordAction.raAdd); GEDCOMFamilyRecord family = null; if (link == PersonLink.plPerson) { iMain = iRec; string evName = ""; if (rbSK_Met.Checked) { switch (cbEventType.SelectedIndex) { case 0: evName = "BIRT"; break; case 1: evName = "DEAT"; break; case 2: evName = "MARR"; break; } } if (evName == "BIRT" || evName == "DEAT") { GEDCOMCustomEvent evt = fBase.Context.CreateEventEx(iRec, evName, GEDCOMDate.CreateByFormattedStr(edEventDate.Text, false), ""); evt.Place.StringValue = place; } else if (evName == "MARR") { family = iRec.GetMarriageFamily(true); GEDCOMCustomEvent evt = fBase.Context.CreateEventEx(family, evName, GEDCOMDate.CreateByFormattedStr(edEventDate.Text, false), ""); evt.Place.StringValue = place; } } else if (link > PersonLink.plPerson) { if (iMain == null) { throw new PersonScanException(fLangMan.LS(FLS.LSID_BasePersonInvalid)); } else { switch (link) { case PersonLink.plFather: case PersonLink.plMother: family = iMain.GetParentsFamily(true); family.AddSpouse(iRec); break; case PersonLink.plGodparent: iMain.AddAssociation(fLangMan.LS(FLS.LSID_PLGodparent), iRec); break; case PersonLink.plSpouse: family = iMain.GetMarriageFamily(true); family.AddSpouse(iRec); break; case PersonLink.plChild: family = iMain.GetMarriageFamily(true); family.AddChild(iRec); break; } } } } } InitSourceControls(); }
private AncPersonSegment TraverseAncestors(GEDCOMIndividualRecord iRec, float v, int gen, float rad, float ro, int prevSteps, int groupIndex) { try { fIndividualsCount++; if (fGroupsMode && groupIndex == -1) { AncPersonSegment otherSegment = (AncPersonSegment)FindSegmentByRec(iRec); if (otherSegment != null) { fGroupCount++; groupIndex = fGroupCount; TraverseGroups(otherSegment, groupIndex); } } int genSize = 1 << gen; float ang = (360.0f / genSize); int idx = prevSteps + (int)(v / ang); AncPersonSegment segment = SetSegmentParams(idx, iRec, rad, groupIndex); if (segment != null && gen < fVisibleGenerations) { float inRad = rad; float extRad = rad + fGenWidth; segment.IntRad = inRad - 50; segment.ExtRad = extRad - 50; GEDCOMIndividualRecord father = null, mother = null; GEDCOMFamilyRecord fam = iRec.GetParentsFamily(); if (fam != null && fBase.Context.IsRecordAccess(fam.Restriction)) { father = fam.GetHusband(); mother = fam.GetWife(); } int ps = prevSteps + genSize; if (father != null) { v -= (Math.Abs(ang - ro) / 2.0f); segment.FatherSegment = TraverseAncestors(father, v, gen + 1, rad + fGenWidth, ro / 2.0f, ps, groupIndex); } if (mother != null) { v += (ang / 2.0f); segment.MotherSegment = TraverseAncestors(mother, v, gen + 1, rad + fGenWidth, ro / 2.0f, ps, groupIndex); } } return(segment); } catch { return(null); } }
public void BuildAncTree() { fSegments.Clear(); const float startRad = CircleChartModel.CENTER_RAD - 50; float inRad = startRad; AncPersonSegment segment = new AncPersonSegment(0); DefineSegment(segment, 0, 0, inRad, 0 - 90.0f, 360.0f); fSegments.Add(segment); int maxSteps = 1; for (int gen = 1; gen <= fVisibleGenerations; gen++) { inRad = startRad + ((gen - 1) * fGenWidth); float extRad = inRad + fGenWidth; maxSteps *= 2; float wedgeAngle = (360.0f / maxSteps); for (int step = 0; step < maxSteps; step++) { float startAngle = (step * wedgeAngle) - 90.0f; segment = new AncPersonSegment(gen); DefineSegment(segment, 0, inRad, extRad, startAngle, wedgeAngle); 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); } }
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); } }
private void ExposePerson(GEDCOMIndividualRecord iRec, string iName) { fWriter.BeginParagraph(TextAlignment.taLeft, 0, 0, 0, true); fWriter.AddParagraphChunkAnchor(iName, fBoldFont, iRec.XRef); fWriter.AddParagraphChunk(GKUtils.GetPedigreeLifeStr(iRec, PedigreeFormat.Compact), fTextFont); fWriter.EndParagraph(); IImage image = fBase.Context.GetPrimaryBitmap(iRec, 0, 0, false); fWriter.AddImage(image); GEDCOMIndividualRecord father, mother; GEDCOMFamilyRecord fam = iRec.GetParentsFamily(); if (fam == null) { father = null; mother = null; } else { father = fam.GetHusband(); mother = fam.GetWife(); } if (father != null) { fWriter.BeginParagraph(TextAlignment.taLeft, 0, 0, 0); fWriter.AddParagraphChunk(LangMan.LS(LSID.LSID_Father) + ": ", fTextFont); fWriter.AddParagraphChunkLink(GKUtils.GetNameString(father, true, false), fLinkFont, father.XRef); fWriter.EndParagraph(); } if (mother != null) { fWriter.BeginParagraph(TextAlignment.taLeft, 0, 0, 0); fWriter.AddParagraphChunk(LangMan.LS(LSID.LSID_Mother) + ": ", fTextFont); fWriter.AddParagraphChunkLink(GKUtils.GetNameString(mother, true, false), fLinkFont, mother.XRef); fWriter.EndParagraph(); } if (IncludeEvents && iRec.Events.Count != 0) { int num = iRec.Events.Count; for (int i = 0; i < num; i++) { GEDCOMCustomEvent evt = iRec.Events[i]; if (evt.Name == "BIRT" || evt.Name == "DEAT") { continue; } string evtName = GKUtils.GetEventName(evt); string evtVal = evt.StringValue; string evtDesc = GKUtils.GetEventDesc(evt, false); string tmp = evtName + ": " + evtVal; if (evtVal != "") { tmp += ", "; } tmp += evtDesc; fWriter.AddParagraph(tmp, fTextFont); } } if (IncludeNotes && iRec.Notes.Count != 0) { int num = iRec.Notes.Count; for (int i = 0; i < num; i++) { GEDCOMNotes note = iRec.Notes[i]; fWriter.AddParagraph(GKUtils.MergeStrings(note.Notes), fTextFont); } } }