private void btnPatSearch_Click(object sender, EventArgs e) { ListPatriarchs.BeginUpdate(); ExtList <PatriarchObj> lst = null; try { ListPatriarchs.ClearItems(); lst = PatriarchsMan.GetPatriarchsList(fBase.Context, (int)edMinGens.Value, !chkWithoutDates.Checked.GetValueOrDefault()); lst.QuickSort(PatriarchsCompare); int num = lst.Count; for (int i = 0; i < num; i++) { PatriarchObj pObj = lst[i]; string pSign = ((pObj.IRec.Patriarch) ? "[*] " : ""); ListPatriarchs.AddItem(pObj.IRec, new object[] { pSign + GKUtils.GetNameString(pObj.IRec, true, false), pObj.BirthYear, pObj.DescendantsCount, pObj.DescGenerations }); } } finally { if (lst != null) { lst.Dispose(); } ListPatriarchs.EndUpdate(); } }
public static ExtList <PatriarchObj> GetPatriarchsLinks(IBaseContext context, int gensMin, bool datesCheck, bool loneSuppress) { ExtList <PatriarchObj> patList = GetPatriarchsList(context, gensMin, datesCheck); IProgressController progress = AppHost.Progress; progress.ProgressInit(LangMan.LS(LSID.LSID_LinksSearch), patList.Count); try { int num2 = patList.Count; for (int i = 0; i < num2; i++) { PatriarchObj patr = patList[i]; for (int j = i + 1; j < num2; j++) { PatriarchObj patr2 = patList[j]; GEDCOMIndividualRecord cross = TreeTools.PL_SearchDesc(patr.IRec, patr2.IRec); if (cross != null) { patr.HasLinks = true; patr2.HasLinks = true; if (cross.Sex == GEDCOMSex.svFemale) { patr.Links.Add(patr2); } else { patr2.Links.Add(patr); } } } progress.ProgressStep(); } } finally { progress.ProgressDone(); } if (loneSuppress) { for (int i = patList.Count - 1; i >= 0; i--) { PatriarchObj patr = patList[i]; if (!patr.HasLinks) { patList.Delete(i); } } patList.Pack(); } return(patList); }
public void Search() { fView.PatriarchsList.BeginUpdate(); ExtList <PatriarchObj> lst = null; try { fView.PatriarchsList.ClearItems(); lst = PatriarchsMan.GetPatriarchsList(fBase.Context, (int)fView.MinGensNum.Value, !fView.WithoutDatesCheck.Checked); lst.QuickSort(PatriarchsCompare); int num = lst.Count; for (int i = 0; i < num; i++) { PatriarchObj pObj = lst[i]; string pSign = ((pObj.IRec.Patriarch) ? "[*] " : ""); fView.PatriarchsList.AddItem(pObj.IRec, new object[] { pSign + GKUtils.GetNameString(pObj.IRec, true, false), pObj.BirthYear, pObj.DescendantsCount, pObj.DescGenerations }); } } finally { if (lst != null) { lst.Dispose(); } fView.PatriarchsList.EndUpdate(); } }
public static ExtList <PatriarchObj> GetPatriarchsList(IBaseContext context, int gensMin, bool datesCheck) { ExtList <PatriarchObj> patList = new ExtList <PatriarchObj>(true); IProgressController progress = AppHost.Progress; progress.ProgressInit(LangMan.LS(LSID.LSID_PatSearch), context.Tree.RecordsCount); GKUtils.InitExtCounts(context.Tree, -1); try { int num = context.Tree.RecordsCount; for (int i = 0; i < num; i++) { GEDCOMRecord rec = context.Tree[i]; if (rec is GEDCOMIndividualRecord) { GEDCOMIndividualRecord iRec = rec as GEDCOMIndividualRecord; var parts = GKUtils.GetNameParts(iRec); int birthDate = context.FindBirthYear(iRec); int descGens = GKUtils.GetDescGenerations(iRec); bool res = (iRec.ChildToFamilyLinks.Count == 0); res = (res && iRec.Sex == GEDCOMSex.svMale); res = (res && /*nf != "" && nf != "?" &&*/ parts.Name != "" && parts.Name != "?"); res = (res && descGens >= gensMin); if (datesCheck) { res = (res && birthDate != 0); } if (res) { PatriarchObj pObj = new PatriarchObj(); pObj.IRec = iRec; pObj.BirthYear = birthDate; pObj.DescendantsCount = GKUtils.GetDescendantsCount(iRec) - 1; pObj.DescGenerations = descGens; patList.Add(pObj); } } progress.ProgressStep(); } } finally { progress.ProgressDone(); } return(patList); }
public void Test_PG() { PatriarchObj pObj = new PatriarchObj(); Assert.IsNotNull(pObj); Assert.IsNotNull(pObj.Links); PGNode pgNode = new PGNode("label", PGNodeType.Default); Assert.IsNotNull(pgNode); pgNode = new PGNode("label", PGNodeType.Default, 5); Assert.IsNotNull(pgNode); }
private void PreparePatriarchs() { using (ExtList <PatriarchObj> lst = PatriarchsMan.GetPatriarchsList(fBase.Context, 2, false)) { lst.QuickSort(PatriarchsCompare); int num = lst.Count; for (int i = 0; i < num; i++) { PatriarchObj pObj = lst[i]; fPatList.AddObject(GKUtils.GetNameString(pObj.IRec, true, false), pObj.IRec); } } }
public void CreateArborGraph(IBaseWindow baseWin, int minGens, bool loneSuppress) { fBase = baseWin; try { fSys = new ArborSystem(1000, 1000, 0.1, null); //(10000, 1000, 0.1, this); fSys.setScreenSize(50, 50); fSys.OnStop += OnArborStop; using (ExtList <PatriarchObj> patList = PatriarchsMan.GetPatriarchsLinks( baseWin.Context, minGens, false, loneSuppress)) { int num = patList.Count; for (int i = 0; i < num; i++) { PatriarchObj pObj = patList[i]; if (!loneSuppress || pObj.HasLinks) { ArborNode node = fSys.addNode(pObj.IRec.XRef); node.Data = pObj; } } for (int i = 0; i < num; i++) { PatriarchObj pat1 = patList[i]; foreach (PatriarchObj pat2 in pat1.Links) { fSys.addEdge(pat1.IRec.XRef, pat2.IRec.XRef); } } } z = -50; fSys.start(); } catch (Exception ex) { Logger.LogWrite("TreeVizControl.CreateArborGraph(): " + ex.Message); } }
public void OnArborStop(object sender, EventArgs eArgs) { FreeRotate = false; fMinYear = 0; try { // load from ArborSystem points and signatures of the patriarchs foreach (ArborNode node in fSys.Nodes) { PatriarchObj patObj = (PatriarchObj)node.Data; GEDCOMIndividualRecord iRec = (GEDCOMIndividualRecord)fBase.Context.Tree.XRefIndex_Find(node.Sign); int descGens = patObj.DescGenerations; TVPerson patr = PreparePerson(null, iRec, TVPersonType.Patriarch); if (patr != null) { patr.Pt = new PointF((float)node.Pt.X * MAGIC_SCALE, (float)node.Pt.Y * MAGIC_SCALE); patr.DescGenerations = descGens; patr.BaseRadius = 100; ProcessPersonStem(patr, null, TVPersonType.Patriarch); if (fMinYear == 0) { fMinYear = patr.BirthYear; } else { if (fMinYear > patr.BirthYear) { fMinYear = patr.BirthYear; } } } } // prepare the radii of the bases of the patriarchs foreach (ArborEdge edge in fSys.Edges) { TVPerson srcPers = FindPersonByXRef(edge.Source.Sign); TVPerson tgtPers = FindPersonByXRef(edge.Target.Sign); if (srcPers == null || tgtPers == null) { continue; } float rad = (float)Dist(srcPers.Pt, tgtPers.Pt) * 3 / 7; if (srcPers.BaseRadius > rad) { srcPers.BaseRadius = rad; } if (tgtPers.BaseRadius > rad) { tgtPers.BaseRadius = rad; } } // prepare the range of years fMaxYear = DateTime.Now.Year; fYearSize = BASE_SCALE / (fMaxYear - fMinYear); fTick = 0; fCurYear = fMinYear; // prepare tree, the base number - only the patriarchs int count = fPersons.Count; for (int i = 0; i < count; i++) { TVPerson prs = fPersons[i]; PrepareDescendants(prs); } for (int i = 0; i < fStems.Count; i++) { TVStem stem = fStems[i]; stem.Update(); } StartTimer(); } catch (Exception ex) { Logger.LogWrite("TreeVizControl.onArborStop(): " + ex.Message); } }
private static int PatriarchsCompare(PatriarchObj item1, PatriarchObj item2) { return(item2.DescendantsCount - item1.DescendantsCount); }
public static Graph GetPatriarchsGraph(IBaseContext context, int gensMin, bool datesCheck, bool loneSuppress) { Graph graph = new Graph(); try { using (ExtList <PatriarchObj> patList = GetPatriarchsList(context, gensMin, datesCheck)) { // init GKUtils.InitExtData(context.Tree); // prepare int count = patList.Count; for (int i = 0; i < count; i++) { PatriarchObj patNode = patList[i]; GEDCOMIndividualRecord iRec = patNode.IRec; int count2 = iRec.SpouseToFamilyLinks.Count; for (int k = 0; k < count2; k++) { GEDCOMFamilyRecord family = iRec.SpouseToFamilyLinks[k].Family; family.ExtData = new PGNode(family.XRef, PGNodeType.Patriarch, patNode.DescGenerations); } } IProgressController progress = AppHost.Progress; try { int patCount = patList.Count; progress.ProgressInit(LangMan.LS(LSID.LSID_LinksSearch), patCount); for (int i = 0; i < patCount; i++) { PatriarchObj patr = patList[i]; for (int j = i + 1; j < patCount; j++) { PatriarchObj patr2 = patList[j]; GEDCOMFamilyRecord cross = TreeTools.PL_SearchIntersection(patr.IRec, patr2.IRec); if (cross != null) { PGNode node = (PGNode)cross.ExtData; if (node != null && node.Type == PGNodeType.Patriarch) { // dummy } else { int size = GKUtils.GetDescGenerations(cross.GetHusband()); if (size == 0) { size = 1; } cross.ExtData = new PGNode(cross.XRef, PGNodeType.Intersection, size); } } } progress.ProgressStep(); } } finally { progress.ProgressDone(); } // create graph int count3 = patList.Count; for (int i = 0; i < count3; i++) { PatriarchObj patNode = patList[i]; PL_WalkDescLinks(graph, null, patNode.IRec); } // clear GKUtils.InitExtData(context.Tree); /*if (gpl_params.aLoneSuppress) { * for (int i = aList.Count - 1; i >= 0; i--) { * PatriarchObj patr = aList[i] as PatriarchObj; * if (patr.ILinks.Count == 0) aList.Delete(i); * } * aList.Pack();*/ } } catch (Exception ex) { Logger.LogWrite("PatriarchsMan.GetPatriarchsGraph(): " + ex.Message); } return(graph); }