Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/person.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/person.py')
-rw-r--r--src/person.py46
1 files changed, 8 insertions, 38 deletions
diff --git a/src/person.py b/src/person.py
index c960fa3..c0f89bf 100644
--- a/src/person.py
+++ b/src/person.py
@@ -20,9 +20,9 @@ const._person_fontsize = 8
class Person:
"Class to represent a person in the tree"
- def __init__(self, name, sex):
+ def __init__(self, name, sex, id=None):
"Constructor: build"
- self.id = Guid().newid()
+ self.id = Guid().newid(id)
self.name = name
self.birthdate = PartialDate()
self.deathdate = PartialDate()
@@ -51,7 +51,7 @@ class Person:
def tostring(self, level=1):
"Translate to a formatted string, tree is horizontal"
- buf = 'P'+str(self.id)+'\n'
+ buf = "P"+str(self.id)+'\n'
if self.unions == []:
buf += '\t'*level + self.name + " " + self.sex
else:
@@ -71,8 +71,10 @@ class Person:
if self.unions == []:
return 1
totlen = 0
- for u in self.unions:
+ for i, u in enumerate(self.unions):
totlen = totlen + u.size_desc()
+ if i != 0:
+ totlen = totlen+self.unions[i-1].child_count()
return totlen
@@ -85,7 +87,7 @@ class Person:
"Compute number of childs"
totchild = 0
for u in self.unions:
- totchild = totchild + len(u.childs)
+ totchild = totchild + u.child_count()
return totchild
@@ -120,7 +122,7 @@ class Person:
for i, u in enumerate(self.unions):
# Next union
if i != 0:
- size = u.size_desc()+self.unions[i-1].size_desc()
+ size = u.size_desc()+self.unions[i-1].child_count()
x = x + (size*const._person_width+size*self.width_margin())/2
# Set conjoint position
@@ -136,38 +138,6 @@ class Person:
# Shift right
size = u.size_desc()
x = x + (size*const._person_width+size*self.width_margin())/2
-
-
- def compute_asc_pos(self):
- "Compute ascendant and its subtree draw starting at origin"
- if self.parents is None:
- return
-
- # Set parent position
- #size = self.parents.size_desc()
- dad = self.parents.dad
- mum = self.parents.mum
- if len(self.unions) == 0:
- x = self.x0 - (const._person_width+self.width_margin())/2
- else:
- conjoint = self.unions[0].conjoint(self)
- if conjoint.parents is None:
- x = self.x0 - (const._person_width+self.width_margin())/2
- elif self.x0 < conjoint.x0:
- size = 1
- x = self.x0 - (size*3*const._person_width+size*self.width_margin())/2
- else:
- size = 1
- x = self.x0 + (size*const._person_width+size*self.width_margin())/2
- y = self.y0 - const._person_height - self.height_margin()
- dad.set_pos(x, y)
- mum.set_pos(x + const._person_width+self.width_margin(), y)
-
- # Set parent parent position and their child
- dad.compute_asc_pos()
- mum.compute_asc_pos()
- dad.compute_desc_pos(dad.x0, dad.y0)
- mum.compute_desc_pos(mum.x0, mum.y0)
def translate(self, dx, dy):