From a90191199e89758353f241917380c03178c0c599 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 5 May 2004 02:04:30 +0000 Subject: [PATCH] * src/SubstKeywords.py (__init__): Convert to db. * src/plugins/AncestorChart.py: Convert to db. * src/plugins/AncestorChart2.py: Convert to db. * src/GraphLayout.py: Convert to db. * src/plugins/DesGraph.py: Convert to db. * src/plugins/FanChart.py: Convert to db. * src/Sort.py: Add converted sort.py to CVS. * src/sort.py: Remove file (obsolete). * src/plugins/TimeLine.py: Convert to db. svn: r3127 --- ChangeLog | 10 ++ src/GraphLayout.py | 35 ++++--- src/{sort.py => Sort.py} | 76 +++++++++----- src/SubstKeywords.py | 63 ++++++++---- src/plugins/AncestorChart.py | 184 +++++----------------------------- src/plugins/AncestorChart2.py | 178 ++++---------------------------- src/plugins/DesGraph.py | 132 +++++------------------- src/plugins/FanChart.py | 56 +++++++---- src/plugins/TimeLine.py | 78 ++++++++------ 9 files changed, 278 insertions(+), 534 deletions(-) rename src/{sort.py => Sort.py} (56%) diff --git a/ChangeLog b/ChangeLog index 75fb32f13..b75f737c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,16 @@ * src/plugins/IndivSummary.py (get_xpm_image): Remove function, import it from Utils.py instead; Convert to db. + * src/SubstKeywords.py (__init__): Convert to db. + * src/plugins/AncestorChart.py: Convert to db. + * src/plugins/AncestorChart2.py: Convert to db. + * src/GraphLayout.py: Convert to db. + * src/plugins/DesGraph.py: Convert to db. + * src/plugins/FanChart.py: Convert to db. + * src/Sort.py: Add converted sort.py to CVS. + * src/sort.py: Remove file (obsolete). + * src/plugins/TimeLine.py: Convert to db. + 2004-05-03 Alex Roitman * src/plugins/DetDescendantReport.py: Convert to db interface. * src/plugins/DetAncestralReport.py: Translate string. diff --git a/src/GraphLayout.py b/src/GraphLayout.py index 8c928f9e8..1bdc40fe0 100644 --- a/src/GraphLayout.py +++ b/src/GraphLayout.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000 Donald N. Allingham +# Copyright (C) 2000-2004 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,11 +18,14 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + class GraphLayout: - def __init__(self,plist,person): + def __init__(self,database,plist,person_id): + self.database = database self.plist = plist - self.person = person + self.person_id = person_id self.v = [] self.e = [] self.maxx = 0 @@ -38,33 +41,37 @@ class DescendLine(GraphLayout): def layout(self): self.elist = [(0,0)] - self.space_for(self.person) + self.space_for(self.person_id) return (self.v,self.e[1:]) - def space_for(self,person,level=1.0,pos=1.0): + def space_for(self,person_id,level=1.0,pos=1.0): last = self.elist[-1] self.elist.append((level,pos)) self.e.append((last[0],last[1],level,pos)) - self.v.append((person,level,pos)) + self.v.append((person_id,level,pos)) if level > self.maxx: self.maxx = level if pos > self.maxy: self.maxy = pos - for family in person.get_family_id_list(): - for child in family.get_child_id_list(): - self.space_for(child,level+1.0,pos) - pos = pos + max(self.depth(child),1) + person = self.database.find_person_from_id(person_id) + for family_id in person.get_family_id_list(): + family = self.database.find_family_from_id(family_id) + for child_id in family.get_child_id_list(): + self.space_for(child_id,level+1.0,pos) + pos = pos + max(self.depth(child_id),1) if pos > self.maxy: self.maxy = pos self.elist.pop() - def depth(self,person,val=0): - for family in person.get_family_id_list(): + def depth(self,person_id,val=0): + person = self.database.find_person_from_id(person_id) + for family_id in person.get_family_id_list(): + family = self.database.find_family_from_id(family_id) clist = family.get_child_id_list() val = val + len(clist) - for child in clist: - d=self.depth(child) + for child_id in clist: + d = self.depth(child_id) if d > 0: val = val + d - 1 #first child is always on the same return val #row as the parent, so subtract 1 diff --git a/src/sort.py b/src/Sort.py similarity index 56% rename from src/sort.py rename to src/Sort.py index 103744331..2abd6c710 100644 --- a/src/sort.py +++ b/src/Sort.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000 Donald N. Allingham +# Copyright (C) 2000-2004 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,6 +17,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # + +# $Id$ + """ Provides sorting routines for use in GRAMPS. Since these functions are intended to provide fast sorting, they tend to bypass access methods, @@ -68,31 +71,52 @@ def build_sort_date(n): d = 99 return "%04d%02d%02d" % (y,m,d) -def by_last_name(first, second): - """Sort routine for comparing two last names. If last names are equal, - uses the given name and suffix""" - name1 = first.get_primary_name() - name2 = second.get_primary_name() +class Sort: + def __init__(self,database): + self.database = database - fsn = name1.get_surname().upper() - ssn = name2.get_surname().upper() - if fsn == ssn : - ffn = name1.get_first_name().upper() - sfn = name2.get_first_name().upper() - if ffn == sfn : - return cmp(name1.get_suffix().upper(), name2.get_suffix().upper()) - else : - return cmp(ffn, sfn) - else : - return cmp(fsn, ssn) + def by_last_name(self,first_id,second_id): + """Sort routine for comparing two last names. If last names are equal, + uses the given name and suffix""" + first = self.database.find_person_from_id(first_id) + second = self.database.find_person_from_id(second_id) + + name1 = first.get_primary_name() + name2 = second.get_primary_name() -def by_birthdate(first, second) : - """Sort routine for comparing two people by birth dates. If the birth dates - are equal, sorts by name""" - date1 = first.get_birth().get_date_object() - date2 = second.get_birth().get_date_object() - val = Date.compare_dates(date1,date2) - if val == 0: - return by_last_name(first,second) - return val + fsn = name1.get_surname().upper() + ssn = name2.get_surname().upper() + + if fsn == ssn : + ffn = name1.get_first_name().upper() + sfn = name2.get_first_name().upper() + if ffn == sfn: + return cmp(name1.get_suffix().upper(), name2.get_suffix().upper()) + else: + return cmp(ffn, sfn) + else: + return cmp(fsn, ssn) + + def by_birthdate(self,first_id,second_id): + """Sort routine for comparing two people by birth dates. If the birth dates + are equal, sorts by name""" + first = self.database.find_person_from_id(first_id) + second = self.database.find_person_from_id(second_id) + + birth_id1 = first.get_birth_id() + if birth_id1: + date1 = self.database.find_event_from_id(birth_id1).get_date_object() + else: + date1 = Date.Date() + + birth_id2 = second.get_birth_id() + if birth_id2: + date2 = self.database.find_event_from_id(birth_id2).get_date_object() + else: + date2 = Date.Date() + + val = Date.compare_dates(date1,date2) + if val == 0: + return self.by_last_name(first_id,second_id) + return val diff --git a/src/SubstKeywords.py b/src/SubstKeywords.py index 16dde41a2..ec6218b86 100644 --- a/src/SubstKeywords.py +++ b/src/SubstKeywords.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000 Donald N. Allingham +# Copyright (C) 2000-2004 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + """ Provides the SubstKeywords class that will replace keywords in a passed string with informatin about the person. For sample: @@ -63,36 +65,61 @@ class SubstKeywords: $M -> Place of preferred marriage """ - def __init__(self,person): + def __init__(self,database,person_id): """Creates a new object and associates a person with it.""" + person = database.find_person_from_id(person_id) self.n = person.get_primary_name().get_regular_name() self.N = person.get_primary_name().get_name() - self.b = person.get_birth().get_date() - self.d = person.get_death().get_date() - self.B = person.get_birth().get_place_name() - self.D = person.get_death().get_place_name() - self.i = str(person.get_id()) - + self.b = "" + self.B = "" + self.d = "" + self.D = "" self.s = "" self.S = "" self.m = "" self.M = "" + birth_id = person.get_birth_id() + if birth_id: + birth = database.find_event_from_id(birth_id) + self.b = birth.get_date() + bplace_id = birth.get_place_id() + if bplace_id: + self.B = database.find_place_from_id(bplace_id).get_title() + death_id = person.get_death_id() + if death_id: + death = database.find_event_from_id(death_id) + self.d = death.get_date() + dplace_id = death.get_place_id() + if dplace_id: + self.D = database.find_place_from_id(dplace_id).get_title() + self.i = str(person_id) + if person.get_family_id_list(): - f = person.get_family_id_list()[0] - if f.get_father_id() == person: - if f.get_mother_id(): - self.s = f.get_mother_id().get_primary_name().get_regular_name() - self.S = f.get_mother_id().get_primary_name().get_name() + f_id = person.get_family_id_list()[0] + f = database.find_family_from_id(f_id) + father_id = f.get_father_id() + mother_id = f.get_mother_id + if father_id == person_id: + if mother_id: + mother = database.find_person_from_id(mother_id) + self.s = mother.get_primary_name().get_regular_name() + self.S = mother.get_primary_name().get_name() else: - if f.get_father_id(): - self.s = f.get_father_id().get_primary_name().get_regular_name() - self.S = f.get_father_id().get_primary_name().get_name() - for e in f.get_event_list(): + if father_id: + father = database.find_person_from_id(father_id) + self.s = father.get_primary_name().get_regular_name() + self.S = father.get_primary_name().get_name() + for e_id in f.get_event_list(): + if not e_id: + continue + e = database.find_event_from_id(e_id) if e.get_name() == 'Marriage': self.m = e.get_date() - self.M = e.get_place_name() + mplace_id = e.get_place_id() + if mplace_id: + self.M = database.find_place_from_id(mplace_id).get_title() def replace(self,line): """Returns a new line of text with the substitutions performed.""" diff --git a/src/plugins/AncestorChart.py b/src/plugins/AncestorChart.py index 9fe47506d..476f3c881 100644 --- a/src/plugins/AncestorChart.py +++ b/src/plugins/AncestorChart.py @@ -49,6 +49,7 @@ import Errors import FontScale from QuestionDialog import ErrorDialog from SubstKeywords import SubstKeywords +from Utils import get_xpm_image from gettext import gettext as _ _BORN = _('b.') @@ -70,6 +71,7 @@ def pt2cm(pt): class AncestorChart: def __init__(self,database,person,max,display,doc,output,newpage=0): + self.database = database self.doc = doc self.doc.creator(database.get_researcher().get_name()) self.map = {} @@ -77,8 +79,8 @@ class AncestorChart: self.start = person self.max_generations = max self.output = output - self.box_width = 0 - self.height = 0 + self.box_width = 0 + self.height = 0 self.lines = 0 self.display = display self.newpage = newpage @@ -87,32 +89,34 @@ class AncestorChart: self.doc.open(output) else: self.standalone = 0 - self.calc() + self.calc() - def filter(self,person,index): + def filter(self,person_id,index): """traverse the ancestors recursively until either the end of a line is found, or until we reach the maximum number of generations that we want to deal with""" - if person == None or index >= 2**self.max_generations: + if (not person_id) or (index >= 2**self.max_generations): return - self.map[index] = person + self.map[index] = person_id - self.text[index] = [] + self.text[index] = [] - subst = SubstKeywords(person) + subst = SubstKeywords(self.database,person_id) for line in self.display: self.text[index].append(subst.replace(line)) self.font = self.doc.style_list["AC-Normal"].get_font() - for line in self.text[index]: - self.box_width = max(self.box_width,FontScale.string_width(self.font,line)) + for line in self.text[index]: + self.box_width = max(self.box_width,FontScale.string_width(self.font,line)) - self.lines = max(self.lines,len(self.text[index])) + self.lines = max(self.lines,len(self.text[index])) - family = person.get_main_parents_family_id() - if family != None: + person = self.database.find_person_from_id(person_id) + family_id = person.get_main_parents_family_id() + if family_id: + family = self.database.find_family_from_id(family_id) self.filter(family.get_father_id(),index*2) self.filter(family.get_mother_id(),(index*2)+1) @@ -144,13 +148,13 @@ class AncestorChart: that and the page dimensions, calculate the proper place to put the elements on a page. """ - self.filter(self.start,1) + self.filter(self.start.get_id(),1) - self.height = self.lines*pt2cm((125.0*self.font.get_size())/100.0) - self.box_width = pt2cm(self.box_width+20) + self.height = self.lines*pt2cm((125.0*self.font.get_size())/100.0) + self.box_width = pt2cm(self.box_width+20) start = 0 - delta = (self.doc.get_usable_width() - (self.box_width + (5.0/10.0)))/3.0 + delta = (self.doc.get_usable_width() - (self.box_width + (5.0/10.0)))/3.0 uh = self.doc.get_usable_height() ystart = -self.height/2.0 @@ -192,9 +196,9 @@ class AncestorChart: def draw_graph(self,index,start,level): if self.map.has_key(start) and index <= 15: - text = self.text[start] + text = self.text[start] - name = string.join(text,"\n") + name = string.join(text,"\n") self.doc.draw_box("AC-box",name,self.x[level],self.y[index-1]) if index > 1: @@ -407,148 +411,6 @@ def write_book_item(database,person,doc,options,newpage=0): import DisplayTrace DisplayTrace.DisplayTrace() -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def get_xpm_image(): - return [ - "48 48 85 1", - " c None", - ". c #887D6C", - "+ c #8C8A87", - "@ c #787775", - "# c #766D5F", - "$ c #67655F", - "% c #5E5A54", - "& c #55524C", - "* c #BBBAB8", - "= c #B7AFA2", - "- c #A9A5A0", - "; c #99948A", - "> c #FAFAFA", - ", c #F8F6F2", - "' c #F6F2EC", - ") c #E6E5E5", - "! c #D2CCBF", - "~ c #C7C6C3", - "{ c #413F3F", - "] c #DCD9D4", - "^ c #322E2B", - "/ c #4F4E4C", - "( c #908F8D", - "_ c #989897", - ": c #8A8986", - "< c #898885", - "[ c #F5EEE5", - "} c #F5F5F5", - "| c #979695", - "1 c #888784", - "2 c #8B8A87", - "3 c #1A1A1A", - "4 c #858582", - "5 c #949390", - "6 c #858480", - "7 c #92918E", - "8 c #8F8E8B", - "9 c #8E8D8A", - "0 c #797773", - "a c #7B7975", - "b c #81807C", - "c c #817F7C", - "d c #989796", - "e c #807E7B", - "f c #8C8B88", - "g c #E3CAA5", - "h c #F2EADF", - "i c #DDCDB4", - "j c #8E8E8B", - "k c #888785", - "l c #EFE4D2", - "m c #969694", - "n c #9F9F9D", - "o c #E6D4B7", - "p c #A5967E", - "q c #8A8987", - "r c #EBDCC4", - "s c #878683", - "t c #9B9995", - "u c #9A9892", - "v c #807F7B", - "w c #7E7C79", - "x c #8E8C88", - "y c #8F8E8C", - "z c #8D8B88", - "A c #B59871", - "B c #878581", - "C c #8E8B87", - "D c #848480", - "E c #898785", - "F c #8A8886", - "G c #7D7B77", - "H c #8D8C89", - "I c #8B8A86", - "J c #918F8B", - "K c #989795", - "L c #BBA382", - "M c #8D8B86", - "N c #868480", - "O c #8E8C87", - "P c #8E8B86", - "Q c #8A8985", - "R c #807F7A", - "S c #8D8A84", - "T c #898884", - " ", - " ", - " .+....@@#####$$$%$%&$@ ", - " .**************=*-;+%%@ ", - " .*>>,>>>>>>,>>>>')!*..;& ", - " .*>>>>>>>>>>>>>>>,)!=@~;{ ", - " .*,>>>>>>>>>>>>>>>,]]%)~+^ ", - " .*>>>>>>>>>>>>>>>>>))/>)~+^ ", - " .*>>>>>>>>>>>>>>>>>(_/>>)~+^ ", - " .*>>>>>>>>>>>>>>>>>:>/)>>)~+{ ", - " @*>>>>>>>>>>>>>>>>><>/]'>>)~;& ", - " @*>>>>>>>>>>>>>>>>>:>/~][>>)~;$ ", - " #*>>>>>>>>>}}|1<<2>:>/33^{{%$@$@ ", - " .*>>>>>>>>>4:<<<<<56>)~*-;+@$%{$ ", - " #*>>>>>>>>><>|<1<7>8>>)!~=-;+@&{ ", - " #*>>>>>>>>><>>>>>>>9>>,]!~*-;+${ ", - " #*>>>>>>>>><>>>>>>>8>>,))~~*-;@^ ", - " #*>>>>>>>>><>>>>>>>:>(000a!~*-@^ ", - " #*>>>>>>>>>1>>>>>>>b2<<<1c]~~*.^ ", - " #*>>>>>>>>><>>>>>>>,>de<>>>>>>>><>>>>>>,,,''[h]]ii~+^ ", - " $*>>jkkkkj><>>>>>,>'''[[hl]]ig;^ ", - " $*>>mkkkkjn<>>>>>,,'''h[hl]o!!p^ ", - " $*>>jkkkkq><>>>>,'''[)[hhll]i!p^ ", - " $*>>>>>>>>><>>>,,'),[hh)llrro!p^ ", - " $*>>>>>>>>><>>,,'''h[hhhllrriip^ ", - " $*>>>>>>>>><>,'''h[hhlllllrroip^ ", - " %*>>>>>>>>><,''''[[hh|>>>>>>>><'''hhh)tu<>>>>>>>,<''['[[hxly<<>>>>>>,,<'hh)hhlxllrrrrrroiA^ ", - " %*>>>>>>,''1[[[[hllxlrlrroooooA^ ", - " %*>>>>>,,''>>>,'''hDEF<<>>,,'''h)hJ<1>,''[[h[[hllllrlCroroooggogA^ ", - " &*>,,''[h[hlhllrlrrCroooooggggA^ ", - " &=,''[[[[hlhllllrrrMoqkk1NogggL^ ", - " &*''''h)hhlllrrrrrrOPQ= 2**self.max_generations: + if (not person_id) or (index >= 2**self.max_generations): return - self.map[index] = person + self.map[index] = person_id - self.text[index] = [] + self.text[index] = [] - subst = SubstKeywords(person) + subst = SubstKeywords(self.database,person_id) for line in self.display: self.text[index].append(subst.replace(line)) - for line in self.text[index]: - self.box_width = max(self.box_width,FontScale.string_width(self.font,line)) + for line in self.text[index]: + self.box_width = max(self.box_width,FontScale.string_width(self.font,line)) - self.lines = max(self.lines,len(self.text[index])) + self.lines = max(self.lines,len(self.text[index])) - family = person.get_main_parents_family_id() - if family: + person = self.database.find_person_from_id(person_id) + family_id = person.get_main_parents_family_id() + if family_id: + family = self.database.find_family_from_id(family_id) self.filter(family.get_father_id(),index*2) self.filter(family.get_mother_id(),(index*2)+1) @@ -279,9 +283,9 @@ class AncestorChart: self.uh = self.doc.get_usable_height() - self.offset uw = self.doc.get_usable_width()-pt2cm(self.box_pad_pts) - calc_width = pt2cm(self.box_width + self.box_pad_pts) + 0.2 - self.box_width = pt2cm(self.box_width) - self.box_height = self.lines*pt2cm(1.25*self.font.get_size()) + calc_width = pt2cm(self.box_width + self.box_pad_pts) + 0.2 + self.box_width = pt2cm(self.box_width) + self.box_height = self.lines*pt2cm(1.25*self.font.get_size()) self.scale = 1 @@ -639,7 +643,7 @@ class AncestorChartBareDialog(Report.BareReportDialog): self.title.set_text(self.the_title) new_name = new_person.getPrimaryName().getRegularName() - if new_name: + if new_name: self.person_label.set_text( "%s" % new_name ) self.person_label.set_use_markup(gtk.TRUE) @@ -692,148 +696,6 @@ def write_book_item(database,person,doc,options,newpage=0): import DisplayTrace DisplayTrace.DisplayTrace() -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def get_xpm_image(): - return [ - "48 48 85 1", - " c None", - ". c #887D6C", - "+ c #8C8A87", - "@ c #787775", - "# c #766D5F", - "$ c #67655F", - "% c #5E5A54", - "& c #55524C", - "* c #BBBAB8", - "= c #B7AFA2", - "- c #A9A5A0", - "; c #99948A", - "> c #FAFAFA", - ", c #F8F6F2", - "' c #F6F2EC", - ") c #E6E5E5", - "! c #D2CCBF", - "~ c #C7C6C3", - "{ c #413F3F", - "] c #DCD9D4", - "^ c #322E2B", - "/ c #4F4E4C", - "( c #908F8D", - "_ c #989897", - ": c #8A8986", - "< c #898885", - "[ c #F5EEE5", - "} c #F5F5F5", - "| c #979695", - "1 c #888784", - "2 c #8B8A87", - "3 c #1A1A1A", - "4 c #858582", - "5 c #949390", - "6 c #858480", - "7 c #92918E", - "8 c #8F8E8B", - "9 c #8E8D8A", - "0 c #797773", - "a c #7B7975", - "b c #81807C", - "c c #817F7C", - "d c #989796", - "e c #807E7B", - "f c #8C8B88", - "g c #E3CAA5", - "h c #F2EADF", - "i c #DDCDB4", - "j c #8E8E8B", - "k c #888785", - "l c #EFE4D2", - "m c #969694", - "n c #9F9F9D", - "o c #E6D4B7", - "p c #A5967E", - "q c #8A8987", - "r c #EBDCC4", - "s c #878683", - "t c #9B9995", - "u c #9A9892", - "v c #807F7B", - "w c #7E7C79", - "x c #8E8C88", - "y c #8F8E8C", - "z c #8D8B88", - "A c #B59871", - "B c #878581", - "C c #8E8B87", - "D c #848480", - "E c #898785", - "F c #8A8886", - "G c #7D7B77", - "H c #8D8C89", - "I c #8B8A86", - "J c #918F8B", - "K c #989795", - "L c #BBA382", - "M c #8D8B86", - "N c #868480", - "O c #8E8C87", - "P c #8E8B86", - "Q c #8A8985", - "R c #807F7A", - "S c #8D8A84", - "T c #898884", - " ", - " ", - " .+....@@#####$$$%$%&$@ ", - " .**************=*-;+%%@ ", - " .*>>,>>>>>>,>>>>')!*..;& ", - " .*>>>>>>>>>>>>>>>,)!=@~;{ ", - " .*,>>>>>>>>>>>>>>>,]]%)~+^ ", - " .*>>>>>>>>>>>>>>>>>))/>)~+^ ", - " .*>>>>>>>>>>>>>>>>>(_/>>)~+^ ", - " .*>>>>>>>>>>>>>>>>>:>/)>>)~+{ ", - " @*>>>>>>>>>>>>>>>>><>/]'>>)~;& ", - " @*>>>>>>>>>>>>>>>>>:>/~][>>)~;$ ", - " #*>>>>>>>>>}}|1<<2>:>/33^{{%$@$@ ", - " .*>>>>>>>>>4:<<<<<56>)~*-;+@$%{$ ", - " #*>>>>>>>>><>|<1<7>8>>)!~=-;+@&{ ", - " #*>>>>>>>>><>>>>>>>9>>,]!~*-;+${ ", - " #*>>>>>>>>><>>>>>>>8>>,))~~*-;@^ ", - " #*>>>>>>>>><>>>>>>>:>(000a!~*-@^ ", - " #*>>>>>>>>>1>>>>>>>b2<<<1c]~~*.^ ", - " #*>>>>>>>>><>>>>>>>,>de<>>>>>>>><>>>>>>,,,''[h]]ii~+^ ", - " $*>>jkkkkj><>>>>>,>'''[[hl]]ig;^ ", - " $*>>mkkkkjn<>>>>>,,'''h[hl]o!!p^ ", - " $*>>jkkkkq><>>>>,'''[)[hhll]i!p^ ", - " $*>>>>>>>>><>>>,,'),[hh)llrro!p^ ", - " $*>>>>>>>>><>>,,'''h[hhhllrriip^ ", - " $*>>>>>>>>><>,'''h[hhlllllrroip^ ", - " %*>>>>>>>>><,''''[[hh|>>>>>>>><'''hhh)tu<>>>>>>>,<''['[[hxly<<>>>>>>,,<'hh)hhlxllrrrrrroiA^ ", - " %*>>>>>>,''1[[[[hllxlrlrroooooA^ ", - " %*>>>>>,,''>>>,'''hDEF<<>>,,'''h)hJ<1>,''[[h[[hllllrlCroroooggogA^ ", - " &*>,,''[h[hlhllrlrrCroooooggggA^ ", - " &=,''[[[[hlhllllrrrMoqkk1NogggL^ ", - " &*''''h)hhlllrrrrrrOPQ c #56524E", - ", c #5E5A56", - "' c #F6EEE6", - ") c #9A968A", - "! c #66665E", - "~ c #F6F2EE", - "{ c #C6C6C1", - "] c #A6967E", - "^ c #8D8A86", - "/ c #736D62", - "( c #E6E6E6", - "_ c #FAFAF9", - ": c #DEDAD6", - "< c #AAA6A2", - "[ c #EEE6D2", - "} c #BABABA", - "| c #878680", - "1 c #8A7E6E", - "2 c #78756F", - "3 c #B89D78", - "4 c #D9CEB9", - " ", - " ", - " 1^111122/////!!!,!,>!2 ", - " 1}}}}}}}}}}}}}}#}<)^,,2 ", - " 1}__~___________~(4}11)> ", - " 1}_______________~(4#+{)* ", - " 1}~_______________~::,({^& ", - " 1}_________________((;_({^& ", - " 1}__|++++___+2//2___+;__({^& ", - " 1}__++++2|||///2/|2|2;(__({^* ", - " +}__|++++_@_+2/22_^_+;:~__({)> ", - " 2}________@_______|__;{:'__({)! ", - " /}________@_______|__;..&**,!2!2 ", - " 1}________@_______|__({}<)^2!,*! ", - " /}________@_______|_|222+#<)^2>* ", - " /}________@_______^^|+22/{}<)@!* ", - " /}________@_________|++++{{}<)+& ", - " /}________@___________~'(:4{}<2& ", - " /}________@__________~~((::{{}1& ", - " /}________^_|+2++__~_~_--%:${}^& ", - " /}________+@2++++__~_~~'-::44{^& ", - " !}________@_+++++~_~~~''-=::$$)& ", - " !}________@_______~~~~-'-[:%{4]& ", - " !}________@_____~~~~'('--=[:4{]& ", - " !}________@_____~~(~'--([[==%4]& ", - " !}________@~+++++~~'++2+2===$4]& ", - " !}________2@+++++||)2+|2/[==%4]& ", - " ,}________+_2++2|''[+222+=%=%$]& ", - " ,}________+~~'~---(-[[[=[==%%4]& ", - " !}________+~~~'~''-=[[===%=%%%3& ", - " ,}_______~+~~--(--[[{=====%=%$]& ", - " ,}_______~+~|+222[[=+1222%%$%%3& ", - " ,}_____~_~++/+++/+/+/222/=%%%$3& ", - " ,}_____~~~-'+2221[2=2212/%%%$$3& ", - " ,}___~_~~~-('-[[[=+=%=%%%%%%$$3& ", - " >}___~~''-''-=[=[=2==%=%%%$$%$3& ", - " >}_~_~~'-'-[-[[===2==%$%$%$$$$3& ", - " >#_~~-'''-[-[[=[==2%22+22$$$$$3& ", - " >}~~~~-(--[[======12/2/2/$$$$$3& ", - " ;#~~-'''-(=[=[==%=%%2+2//$$$$$]& ", - " >#~~-(-=-[[[====%%%%%%$$$$$$$$3& ", - " ;#-~''--[===[==$=%%$%$$$$$$}$$3& ", - " ;#---[[[[[==%==%%$%$%$$$$$$$$$3& ", - " ;#}#######3333333333333333333]3& ", - " &&&&&&&&&*&&*&&*&*&&&&&&&&.&&.&& ", - " ", - " ", - " "] - #------------------------------------------------------------------------ # # diff --git a/src/plugins/FanChart.py b/src/plugins/FanChart.py index 314bb70e4..fe4adb7c7 100644 --- a/src/plugins/FanChart.py +++ b/src/plugins/FanChart.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003 Donald N. Allingham +# Copyright (C) 2003-2004 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + #------------------------------------------------------------------------ # # gnome/gtk @@ -57,14 +59,15 @@ def pt2cm(pt): class FanChart: def __init__(self,database,person,display,doc,output,newpage=0): + self.database = database self.doc = doc self.doc.creator(database.get_researcher().get_name()) self.map = {} self.text = {} self.start = person self.output = output - self.box_width = 0 - self.height = 0 + self.box_width = 0 + self.height = 0 self.lines = 0 self.display = display self.newpage = newpage @@ -135,41 +138,43 @@ class FanChart: self.doc.add_draw_style("FC-c5n",g) self.map = [None] * 32 - self.text= {} + self.text= {} self.box_width = 0 if self.standalone: self.doc.init() - def filter(self,person,index): + def filter(self,person_id,index): """traverse the ancestors recursively until either the end of a line is found, or until we reach the maximum number of generations that we want to deal with""" - if person == None or index >= 32: + if (not person_id) or (index >= 32): return - self.map[index-1] = person + self.map[index-1] = person_id - self.text[index-1] = [] + self.text[index-1] = [] - subst = SubstKeywords(person) + subst = SubstKeywords(self.database,person_id) for line in self.display: self.text[index-1].append(subst.replace(line)) self.font = self.doc.style_list["FC-Normal"].get_font() - for line in self.text[index-1]: - self.box_width = max(self.box_width,string_width(self.font,line)) + for line in self.text[index-1]: + self.box_width = max(self.box_width,string_width(self.font,line)) - self.lines = max(self.lines,len(self.text[index-1])) + self.lines = max(self.lines,len(self.text[index-1])) - family = person.get_main_parents_family_id() - if family != None: + person = self.database.find_person_from_id(person_id) + family_id = person.get_main_parents_family_id() + if family_id: + family = self.database.find_family_from_id(family_id) self.filter(family.get_father_id(),index*2) self.filter(family.get_mother_id(),(index*2)+1) def write_report(self): - self.filter(self.start,1) + self.filter(self.start.get_id(),1) block_size = self.doc.get_usable_width()/14.0 @@ -196,13 +201,24 @@ class FanChart: if self.standalone: self.doc.close() - def get_info(self,person): + def get_info(self,person_id): + person = self.database.find_person_from_id(person_id) pn = person.get_primary_name() - b = person.get_birth().get_date_object().getYear() - d = person.get_death().get_date_object().getYear() - if b == Calendar.UNDEF: + + birth_id = person.get_birth_id() + if birth_id: + b = self.database.find_event_from_id(birth_id).get_date_object().get_year() + if b == Calendar.UNDEF: + b = "" + else: b = "" - if d == Calendar.UNDEF: + + death_id = person.get_death_id() + if death_id: + d = self.database.find_event_from_id(death_id).get_date_object().get_year() + if d == Calendar.UNDEF: + d = "" + else: d = "" if b or d: diff --git a/src/plugins/TimeLine.py b/src/plugins/TimeLine.py index 27c044902..205bf630f 100644 --- a/src/plugins/TimeLine.py +++ b/src/plugins/TimeLine.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003 Donald N. Allingham +# Copyright (C) 2003-2004 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,7 +50,7 @@ import GenericFilter import Errors import Date import FontScale -import sort +import Sort from QuestionDialog import ErrorDialog from gettext import gettext as _ @@ -76,10 +76,10 @@ class TimeLine: class. """ self.d = document - self.filter = filter - self.db = database - self.person = person - self.output = output + self.filter = filter + self.db = database + self.person = person + self.output = output self.title = title self.sort_func = sort_func self.newpage = newpage @@ -183,9 +183,19 @@ class TimeLine: self.plist.sort(self.sort_func) - for p in self.plist: - b = p.get_birth().get_date_object().getYear() - d = p.get_death().get_date_object().getYear() + for p_id in self.plist: + p = self.db.find_person_from_id(p_id) + b_id = p.get_birth_id() + if b_id: + b = self.db.find_event_from_id(b_id).get_date_object().get_year() + else: + b = Date.UNDEF + + d_id = p.get_death_id() + if d_id: + d = self.db.find_event_from_id(d_id).get_date_object().get_year() + else: + d = Date.UNDEF n = p.get_primary_name().get_name() self.d.draw_text('TLG-text',n,incr+pad,self.header + (incr+pad)*index) @@ -267,24 +277,34 @@ class TimeLine: def find_year_range(self): low = 999999 - high = -999999 - - self.plist = self.filter.apply(self.db,self.db.get_person_id_map().values()) + high = -999999 + + self.plist = self.filter.apply(self.db,self.db.get_person_keys()) - for p in self.plist: - b = p.get_birth().get_date_object().getYear() - d = p.get_death().get_date_object().getYear() + for p_id in self.plist: + p = self.db.find_person_from_id(p_id) + b_id = p.get_birth_id() + if b_id: + b = self.db.find_event_from_id(b_id).get_date_object().get_year() + else: + b = Date.UNDEF - if b != Date.UNDEF: - low = min(low,b) - high = max(high,b) + d_id = p.get_death_id() + if d_id: + d = self.db.find_event_from_id(d_id).get_date_object().get_year() + else: + d = Date.UNDEF - if d != Date.UNDEF: - low = min(low,d) - high = max(high,d) + if b != Date.UNDEF: + low = min(low,b) + high = max(high,b) + + if d != Date.UNDEF: + low = min(low,d) + high = max(high,d) - low = (low/10)*10 - high = ((high+9)/10)*10 + low = (low/10)*10 + high = ((high+9)/10)*10 if low == Date.UNDEF: low = high @@ -294,13 +314,14 @@ class TimeLine: return (low,high) def name_size(self): - self.plist = self.filter.apply(self.db,self.db.get_person_id_map().values()) + self.plist = self.filter.apply(self.db,self.db.get_person_keys()) style_name = self.d.draw_styles['TLG-text'].get_paragraph_style() font = self.d.style_list[style_name].get_font() size = 0 - for p in self.plist: + for p_id in self.plist: + p = self.db.find_person_from_id(p_id) n = p.get_primary_name().get_name() size = max(FontScale.string_width(font,n),size) return pt2cm(size) @@ -372,7 +393,7 @@ def _get_report_filters(person): # Builds list of sorting functions for this report # #------------------------------------------------------------------------ -def _get_sort_functions(): +def _get_sort_functions(sort): return [ (_("Birth Date"),sort.by_birthdate), (_("Name"),sort.by_last_name), @@ -388,6 +409,7 @@ class TimeLineDialog(Report.DrawReportDialog): report_options = {} def __init__(self,database,person): + self.database = database Report.DrawReportDialog.__init__(self,database,person,self.report_options) def get_title(self): @@ -421,7 +443,7 @@ class TimeLineDialog(Report.DrawReportDialog): self.sort_style = gtk.OptionMenu() self.sort_menu = gtk.Menu() - sort_functions = _get_sort_functions() + sort_functions = _get_sort_functions(Sort.Sort(self.database)) for item in sort_functions: menuitem = gtk.MenuItem(item[0]) menuitem.set_data('sort',item[1]) @@ -564,7 +586,7 @@ class TimeLineBareDialog(Report.BareReportDialog): self.sort_style = gtk.OptionMenu() self.sort_menu = gtk.Menu() - sort_functions = _get_sort_functions() + sort_functions = _get_sort_functions(Sort.Sort(self.db)) for item in sort_functions: menuitem = gtk.MenuItem(item[0]) menuitem.set_data('sort',item[1])