Delete reports that have been unsupported for > 1 year.
svn: r9517
This commit is contained in:
parent
a579d61dbc
commit
0b5dd35b23
@ -1,3 +1,11 @@
|
||||
2007-12-15 Brian Matherly <brian@gramps-project.org>
|
||||
* src/plugins/FtmStyleAncestors.py
|
||||
* src/plugins/DesGraph.py
|
||||
* src/plugins/Ancestors.py
|
||||
* src/plugins/IndivSummary.py
|
||||
* src/plugins/FtmStyleDescendants.py:
|
||||
Delete reports that have been unsupported for > 1 year.
|
||||
|
||||
2007-12-15 Brian Matherly <brian@gramps-project.org>
|
||||
* src/docgen/PdfDoc.py: Fix application launch.
|
||||
|
||||
|
@ -1,975 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2003-2007 Donald N. Allingham
|
||||
# Copyright (C) 2003 Tim Waugh
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
import os
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# GTK modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import const
|
||||
from PluginUtils import register_report , relationship_class
|
||||
from ReportBase import Report, ReportUtils, ReportOptions, \
|
||||
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
|
||||
import BaseDoc
|
||||
import gen.lib
|
||||
from DateHandler import displayer as _dd
|
||||
from BasicUtils import name_displayer as _nd
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# ComprehensiveAncestorsReport
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class ComprehensiveAncestorsReport (Report):
|
||||
|
||||
def __init__(self,database,person,options_class):
|
||||
"""
|
||||
Creates ComprehensiveAncestorsReport object that produces the report.
|
||||
|
||||
The arguments are:
|
||||
|
||||
database - the GRAMPS database instance
|
||||
person - currently selected person
|
||||
options_class - instance of the Options class for this report
|
||||
|
||||
This report needs the following parameters (class variables)
|
||||
that come in the options class.
|
||||
|
||||
gen - Maximum number of generations to include.
|
||||
pagebbg - Whether to include page breaks between generations.
|
||||
cites - Whether or not to include source informaiton.
|
||||
"""
|
||||
|
||||
Report.__init__(self,database,person,options_class)
|
||||
|
||||
self.map = {}
|
||||
|
||||
(self.max_generations,self.pgbrk) \
|
||||
= options_class.get_report_generations()
|
||||
self.opt_cite = options_class.handler.options_dict['cites']
|
||||
|
||||
self.sources = []
|
||||
self.sourcerefs = []
|
||||
self.RelClass = relationship_class
|
||||
self.relationship = self.RelClass(database)
|
||||
|
||||
def define_table_styles(self):
|
||||
table = BaseDoc.TableStyle ()
|
||||
table.set_column_widths ([15, 85])
|
||||
table.set_width (100)
|
||||
self.doc.add_table_style ("AR-PersonNoSpouse", table)
|
||||
|
||||
table = BaseDoc.TableStyle ()
|
||||
table.set_column_widths ([10, 15, 75])
|
||||
table.set_width (100)
|
||||
self.doc.add_table_style ("AR-ChildNoSpouse", table)
|
||||
|
||||
for nspouse in range (1, 3):
|
||||
table = BaseDoc.TableStyle ()
|
||||
table.set_width (100)
|
||||
widths = [15, 100 - 15 * (nspouse + 1)]
|
||||
widths.extend ([15] * nspouse)
|
||||
table.set_column_widths (widths)
|
||||
self.doc.add_table_style ("AR-PersonWithSpouse%d" % nspouse, table)
|
||||
|
||||
table = BaseDoc.TableStyle ()
|
||||
table.set_width (100)
|
||||
widths = [10, 15, 90 - 15 * (nspouse + 1)]
|
||||
widths.extend ([15] * nspouse)
|
||||
table.set_column_widths (widths)
|
||||
self.doc.add_table_style ("AR-ChildWithSpouse%d"% nspouse, table)
|
||||
|
||||
cell = BaseDoc.TableCellStyle ()
|
||||
cell.set_padding (1) # each side makes 2cm, the size of the photo
|
||||
self.doc.add_cell_style ("AR-PaddedCell", cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle ()
|
||||
cell.set_padding (0.1)
|
||||
self.doc.add_cell_style ("AR-NoPhoto", cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle ()
|
||||
cell.set_padding (0.1)
|
||||
self.doc.add_cell_style ("AR-Photo", cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle ()
|
||||
cell.set_padding (0.1)
|
||||
self.doc.add_cell_style ("AR-Entry", cell)
|
||||
|
||||
def write_report(self):
|
||||
self.sources = []
|
||||
name = self.person_name (self.start_person.get_handle())
|
||||
self.doc.start_paragraph("AR-Title")
|
||||
title = _("Ancestors of %s") % name
|
||||
self.doc.write_text(title)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
self.doc.start_paragraph ("AR-Heading")
|
||||
self.doc.write_text (_("Generation 1"))
|
||||
self.doc.end_paragraph ()
|
||||
|
||||
self.write_paragraphs (self.person (self.start_person.get_handle(),
|
||||
suppress_children = 1,
|
||||
needs_name = 1))
|
||||
family_handles = [self.start_person.get_main_parents_family_handle ()]
|
||||
if len (family_handles) > 0:
|
||||
self.generation (self.max_generations, family_handles, [],
|
||||
[self.start_person.get_handle()])
|
||||
|
||||
if len (self.sources) > 0:
|
||||
if self.pgbrk:
|
||||
self.doc.page_break()
|
||||
|
||||
self.doc.start_paragraph ("AR-Heading")
|
||||
self.doc.write_text (_("Sources"))
|
||||
self.doc.end_paragraph ()
|
||||
|
||||
i = 1
|
||||
for source_handle in self.sources:
|
||||
source = self.database.get_source_from_handle(source_handle)
|
||||
self.doc.start_paragraph ("AR-Entry")
|
||||
self.doc.write_text ("[%d] %s" % (i, source.get_title ()))
|
||||
author = source.get_author ()
|
||||
pubinfo = source.get_publication_info ()
|
||||
extra = author
|
||||
if pubinfo:
|
||||
if extra:
|
||||
extra += ', '
|
||||
extra += pubinfo
|
||||
if extra:
|
||||
self.doc.write_text ('; %s' % extra)
|
||||
self.doc.end_paragraph ()
|
||||
|
||||
note = source.get_note ()
|
||||
format = source.get_note_format ()
|
||||
if note:
|
||||
self.doc.write_note (note, format, "AR-Details")
|
||||
|
||||
i += 1
|
||||
|
||||
return
|
||||
|
||||
def write_paragraphs (self, paragraphs):
|
||||
for (fn, params) in paragraphs:
|
||||
if len (params) == 0:
|
||||
fn ()
|
||||
elif len (params) == 1:
|
||||
fn (params[0])
|
||||
elif len (params) == 2:
|
||||
fn (params[0], params[1])
|
||||
elif len (params) == 3:
|
||||
fn (params[0], params[1], params[2])
|
||||
elif len (params) == 4:
|
||||
fn (params[0], params[1], params[2], params[3])
|
||||
else:
|
||||
self.doc.write_text ("Call to %s with params %s" %
|
||||
(str (fn), str (params)))
|
||||
|
||||
def family (self, family_handle, already_described):
|
||||
ret = []
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
if not family:
|
||||
return ret
|
||||
father_handle = family.get_father_handle ()
|
||||
mother_handle = family.get_mother_handle ()
|
||||
father = self.database.get_person_from_handle(father_handle)
|
||||
mother = self.database.get_person_from_handle(mother_handle)
|
||||
if father:
|
||||
ret.extend (self.person (father_handle,
|
||||
short_form = father_handle in already_described,
|
||||
already_described = already_described,
|
||||
needs_name = not mother,
|
||||
from_family = family))
|
||||
|
||||
if mother:
|
||||
ret.extend (self.person (mother_handle,
|
||||
short_form = mother_handle in already_described,
|
||||
already_described = already_described,
|
||||
needs_name = not father,
|
||||
from_family = family))
|
||||
|
||||
children_ids = family.get_child_handle_list ()
|
||||
if len (children_ids):
|
||||
ret.append ((self.doc.start_paragraph, ['AR-ChildTitle']))
|
||||
ret.append ((self.doc.write_text, [_('Their children:')]))
|
||||
ret.append ((self.doc.end_paragraph, []))
|
||||
|
||||
for child_handle in children_ids:
|
||||
child = self.database.get_person_from_handle(child_handle)
|
||||
ret.extend (self.person (child_handle, suppress_children = 1,
|
||||
short_form=child_handle in already_described,
|
||||
already_described = already_described,
|
||||
needs_name = 1,
|
||||
from_family = family))
|
||||
|
||||
return ret
|
||||
|
||||
def generation (self, generations, pfamily_handles, mfamily_handles,
|
||||
already_described, thisgen = 2):
|
||||
if generations > 1 and (len (pfamily_handles) + len (mfamily_handles)):
|
||||
people = []
|
||||
for family_handle in pfamily_handles:
|
||||
people.extend (self.family (family_handle, already_described))
|
||||
|
||||
paternal_known = (len (people) > 0)
|
||||
if thisgen > 2 and len (mfamily_handles):
|
||||
for self.gp in [self.database.get_family_from_handle(mfamily_handles[0]).get_father_handle (),
|
||||
self.database.get_family_from_handle(mfamily_handles[0]).get_mother_handle ()]:
|
||||
if self.gp:
|
||||
break
|
||||
|
||||
relstring = self.relationship.get_grandparents_string(
|
||||
self.start_person,
|
||||
self.database.get_person_from_handle(self.gp))
|
||||
heading = _("%(name)s's maternal %(grandparents)s") % \
|
||||
{ 'name': self.first_name_or_nick (self.start_person),
|
||||
'grandparents': relstring }
|
||||
people.append ((self.doc.start_paragraph, ['AR-Heading']))
|
||||
people.append ((self.doc.write_text, [heading]))
|
||||
people.append ((self.doc.end_paragraph, []))
|
||||
|
||||
for family_handle in mfamily_handles:
|
||||
people.extend (self.family (family_handle, already_described))
|
||||
|
||||
if len (people):
|
||||
if self.pgbrk:
|
||||
self.doc.page_break()
|
||||
|
||||
family_handles = pfamily_handles
|
||||
family_handles.extend (mfamily_handles)
|
||||
for self.gp in [self.database.get_family_from_handle(family_handles[0]).get_father_handle (),
|
||||
self.database.get_family_from_handle(family_handles[0]).get_mother_handle ()]:
|
||||
if self.gp:
|
||||
break
|
||||
|
||||
if paternal_known:
|
||||
self.doc.start_paragraph ("AR-Heading")
|
||||
relstring = self.relationship.get_grandparents_string(
|
||||
self.start_person,
|
||||
self.database.get_person_from_handle(self.gp))
|
||||
if thisgen == 2:
|
||||
heading = _("%(name)s's %(parents)s") % \
|
||||
{ 'name': self.first_name_or_nick (self.start_person),
|
||||
'parents': relstring }
|
||||
else:
|
||||
heading = _("%(name)s's paternal %(grandparents)s") % \
|
||||
{ 'name': self.first_name_or_nick (self.start_person),
|
||||
'grandparents': relstring }
|
||||
|
||||
self.doc.write_text (heading)
|
||||
self.doc.end_paragraph ()
|
||||
|
||||
self.write_paragraphs (people)
|
||||
|
||||
next_pfamily_handles = []
|
||||
next_mfamily_handles = []
|
||||
for family_handle in family_handles:
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
father_handle = family.get_father_handle ()
|
||||
father = self.database.get_person_from_handle(father_handle)
|
||||
if father:
|
||||
already_described.append (father_handle)
|
||||
father_family_handle = father.get_main_parents_family_handle ()
|
||||
father_family = self.database.get_family_from_handle(father_family_handle)
|
||||
if father_family:
|
||||
next_pfamily_handles.append (father_family_handle)
|
||||
|
||||
mother_handle = family.get_mother_handle ()
|
||||
mother = self.database.get_person_from_handle(mother_handle)
|
||||
if mother:
|
||||
already_described.append (mother_handle)
|
||||
mother_family_handle = mother.get_main_parents_family_handle ()
|
||||
mother_family = self.database.get_family_from_handle(mother_family_handle)
|
||||
if mother_family:
|
||||
next_mfamily_handles.append (mother_family_handle)
|
||||
|
||||
self.generation (generations - 1, next_pfamily_handles,
|
||||
next_mfamily_handles, already_described,
|
||||
thisgen + 1)
|
||||
|
||||
def person (self, person_handle,
|
||||
suppress_children = 0,
|
||||
short_form = 0,
|
||||
already_described = [],
|
||||
needs_name = 0,
|
||||
from_family = None):
|
||||
ret = []
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
name = self.person_name (person_handle)
|
||||
if name:
|
||||
photos = person.get_media_list ()
|
||||
|
||||
bits = ''
|
||||
bits += self.short_occupation (person)
|
||||
bits += self.long_born_died (person)
|
||||
if not suppress_children:
|
||||
bits += self.parents_of (person_handle)
|
||||
else:
|
||||
bits += '.'
|
||||
bits += self.married_whom (person, from_family, suppress_children)
|
||||
bits += self.inline_notes (person)
|
||||
|
||||
longnotes = self.long_notes (person, suppress_children,
|
||||
already_described)
|
||||
|
||||
if (bits != '.' or longnotes or photos or
|
||||
suppress_children or needs_name):
|
||||
# We have something to say about this person.
|
||||
|
||||
spouse = []
|
||||
if from_family:
|
||||
from_family_father_id = from_family.get_father_handle ()
|
||||
from_family_mother_id = from_family.get_mother_handle ()
|
||||
else:
|
||||
from_family_father_id = from_family_mother = None
|
||||
|
||||
for family_handle in person.get_family_handle_list ():
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
for partner_id in [family.get_father_handle (),
|
||||
family.get_mother_handle ()]:
|
||||
partner = self.database.get_person_from_handle(partner_id)
|
||||
if partner_id == person_handle or not partner:
|
||||
continue
|
||||
|
||||
if (suppress_children or
|
||||
(partner_id != from_family_father_id and
|
||||
partner_id != from_family_mother_id)):
|
||||
for media_ref in partner.get_media_list ()[:1]:
|
||||
object_handle = media_ref.get_reference_handle()
|
||||
mobject = self.database.get_object_from_handle(object_handle)
|
||||
if os.path.isfile(mobject.get_path()):
|
||||
mime_type = mobject.get_mime_type()
|
||||
if mime_type and mime_type.startswith("image"):
|
||||
spouse.append ((self.doc.add_media_object,
|
||||
[mobject.get_path (),
|
||||
'right', 2, 2]))
|
||||
|
||||
if suppress_children and len (already_described):
|
||||
style = "AR-Child"
|
||||
else:
|
||||
style = "AR-Person"
|
||||
if len (spouse):
|
||||
style += "WithSpouse%d" % len (spouse)
|
||||
else:
|
||||
style += "NoSpouse"
|
||||
|
||||
ret.append ((self.doc.start_table, [style, style]))
|
||||
ret.append ((self.doc.start_row, []))
|
||||
|
||||
if suppress_children and len (already_described):
|
||||
# Can't do proper formatting with BaseDoc, so cheat.
|
||||
ret.append ((self.doc.start_cell, ["AR-PaddedCell"]))
|
||||
ret.append ((self.doc.end_cell, []))
|
||||
|
||||
if len (photos) == 0:
|
||||
ret.append ((self.doc.start_cell, ["AR-NoPhoto"]))
|
||||
ret.append ((self.doc.start_paragraph, ["AR-NoPhotoText"]))
|
||||
ret.append ((self.doc.end_paragraph, []))
|
||||
ret.append ((self.doc.end_cell, []))
|
||||
else:
|
||||
ret.append ((self.doc.start_cell, ["AR-Photo"]))
|
||||
for media_ref in photos[:1]:
|
||||
object_handle = media_ref.get_reference_handle()
|
||||
mobject = self.database.get_object_from_handle(object_handle)
|
||||
mime_type = mobject.get_mime_type()
|
||||
if os.path.isfile(mobject.get_path()) and \
|
||||
mime_type and mime_type.startswith("image"):
|
||||
ret.append ((self.doc.add_media_object,
|
||||
[mobject.get_path (), 'left', 2, 2]))
|
||||
ret.append ((self.doc.end_cell, []))
|
||||
|
||||
ret.append ((self.doc.start_cell, ["AR-Entry"]))
|
||||
ret.append ((self.doc.start_paragraph, ["AR-Entry"]))
|
||||
ret.append ((self.doc.write_text, [name]))
|
||||
if short_form:
|
||||
ret.append ((self.doc.write_text,
|
||||
[_(" (mentioned above).")]))
|
||||
else:
|
||||
ret.append ((self.doc.write_text, [bits]))
|
||||
|
||||
ret.append ((self.doc.end_paragraph, []))
|
||||
ret.append ((self.doc.end_cell, []))
|
||||
|
||||
for s in spouse:
|
||||
ret.append ((self.doc.start_cell, ["AR-Photo"]))
|
||||
ret.append (s)
|
||||
ret.append ((self.doc.end_cell, []))
|
||||
|
||||
ret.append ((self.doc.end_row, []))
|
||||
ret.append ((self.doc.end_table, []))
|
||||
|
||||
if not short_form:
|
||||
ret.extend (longnotes)
|
||||
|
||||
return ret
|
||||
|
||||
def short_occupation (self, person):
|
||||
occupation = ''
|
||||
for event_handle in person.get_event_list ():
|
||||
if not event_handle:
|
||||
continue
|
||||
event = self.database.get_event_from_handle(event_handle)
|
||||
if event.get_name () == 'Occupation':
|
||||
if occupation:
|
||||
return ''
|
||||
|
||||
occupation = event.get_description ()
|
||||
|
||||
if occupation:
|
||||
return ' (%s)' % occupation
|
||||
|
||||
return ''
|
||||
|
||||
def event_info (self, event):
|
||||
info = ''
|
||||
name = event.get_name ()
|
||||
description = event.get_description ()
|
||||
if name != 'Birth' and name != 'Death' and name != 'Marriage':
|
||||
info += const.display_pevent (name)
|
||||
if description:
|
||||
info += ': ' + description
|
||||
description = None
|
||||
|
||||
dateobj = event.get_date_object ()
|
||||
if dateobj:
|
||||
text = dateobj.get_text()
|
||||
date_text = _dd.display(dateobj)
|
||||
if text:
|
||||
info += ' ' + text[0].lower() + text[1:]
|
||||
elif dateobj.get_valid ():
|
||||
if not dateobj.is_regular():
|
||||
info += ' ' + date_text
|
||||
elif (dateobj.get_day_valid () and
|
||||
dateobj.get_month_valid () and
|
||||
dateobj.get_year_valid ()):
|
||||
info += _(' on %(specific_date)s') % \
|
||||
{'specific_date': date_text}
|
||||
else:
|
||||
info += _(' in %(month_or_year)s') % \
|
||||
{'month_or_year': date_text}
|
||||
|
||||
place = self.database.get_place_from_handle(event.get_place_handle())
|
||||
if place:
|
||||
placename = place.get_title()
|
||||
if placename:
|
||||
info += _(' in %(place)s') % {'place': placename}
|
||||
note = event.get_note ()
|
||||
note_format = event.get_note_format ()
|
||||
inline_note = note and (note_format == 0)
|
||||
if inline_note or description:
|
||||
info += ' ('
|
||||
if description:
|
||||
info += description
|
||||
if note:
|
||||
if description:
|
||||
info += '; '
|
||||
info += note
|
||||
info += ')'
|
||||
|
||||
info += self.cite_sources (event.get_source_references ())
|
||||
return info
|
||||
|
||||
def address_info (self, address):
|
||||
info = _('Address:') + ' %s %s %s %s' % (address.get_street (),
|
||||
address.get_city (),
|
||||
address.get_state (),
|
||||
address.get_country ())
|
||||
|
||||
info = info.rstrip ()
|
||||
date = address.get_date ()
|
||||
if date:
|
||||
info += ', ' + date
|
||||
|
||||
info += self.cite_sources (address.get_source_references ())
|
||||
return info
|
||||
|
||||
def abbrev_born_died (self, person):
|
||||
ret = ''
|
||||
|
||||
birth_ref = person.get_birth_ref()
|
||||
if birth_ref:
|
||||
birth = self.database.get_event_from_handle(birth_ref.ref)
|
||||
date = birth.get_date ()
|
||||
if date:
|
||||
ret += _(" b. %(birth_date)s") % {'birth_date': date}
|
||||
ret += self.cite_sources (birth.get_source_references ())
|
||||
|
||||
death_ref = person.get_death_ref()
|
||||
if death_ref:
|
||||
death = self.database.get_event_from_handle(death_ref.ref)
|
||||
date = death.get_date ()
|
||||
if date:
|
||||
ret += _(" d. %(death_date)s") % {'death_date': date}
|
||||
ret += self.cite_sources (death.get_source_references ())
|
||||
|
||||
return ret
|
||||
|
||||
def long_born_died (self, person):
|
||||
ret = ''
|
||||
born_info = None
|
||||
birth_ref = person.get_birth_ref()
|
||||
if birth_ref:
|
||||
birth = self.database.get_event_from_handle(birth_ref.ref)
|
||||
born_info = self.event_info (birth)
|
||||
if born_info:
|
||||
ret = ", " + _("born") + born_info
|
||||
|
||||
death_ref = person.get_death_ref()
|
||||
if death_ref:
|
||||
death = self.database.get_event_from_handle(death_ref.ref)
|
||||
died_info = self.event_info (death)
|
||||
if died_info:
|
||||
if born_info:
|
||||
ret += '; '
|
||||
else:
|
||||
ret += ', '
|
||||
|
||||
ret += _('died') + died_info
|
||||
|
||||
return ret
|
||||
|
||||
def parents_of (self, person_handle):
|
||||
|
||||
ret = '. '
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
family_handle = person.get_main_parents_family_handle()
|
||||
if family_handle:
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
mother_handle = family.get_mother_handle()
|
||||
father_handle = family.get_father_handle()
|
||||
if mother_handle:
|
||||
mother = self.database.get_person_from_handle(mother_handle)
|
||||
mother_name = _nd.display_name(mother.get_primary_name())
|
||||
else:
|
||||
mother_name = ""
|
||||
if father_handle:
|
||||
father = self.database.get_person_from_handle(father_handle)
|
||||
father_name = _nd.display_name(father.get_primary_name())
|
||||
else:
|
||||
father_name = ""
|
||||
|
||||
ret += ReportUtils.child_str(person,father_name,mother_name,
|
||||
bool(person.get_death_handle()))
|
||||
|
||||
return ret
|
||||
|
||||
def first_name_or_nick (self, person):
|
||||
nickname = person.get_nick_name ()
|
||||
if nickname:
|
||||
return nickname
|
||||
|
||||
name = person.get_primary_name ().get_first_name ()
|
||||
return name.split (' ')[0]
|
||||
|
||||
def title (self, person):
|
||||
name = person.get_primary_name ()
|
||||
t = name.get_title ()
|
||||
if t:
|
||||
return t
|
||||
|
||||
gender = person.get_gender ()
|
||||
if gender == gen.lib.Person.FEMALE:
|
||||
if name.get_type () == 'Married Name':
|
||||
return _('Mrs.')
|
||||
|
||||
return _('Miss')
|
||||
elif gender == gen.lib.Person.MALE:
|
||||
return _('Mr.')
|
||||
else:
|
||||
return _('(gender unknown)')
|
||||
|
||||
def cite_sources (self, sourcereflist):
|
||||
citation = ""
|
||||
if self.opt_cite:
|
||||
for ref in sourcereflist:
|
||||
if ref in self.sourcerefs:
|
||||
continue
|
||||
|
||||
self.sourcerefs.append (ref)
|
||||
source_handle = ref.get_reference_handle ()
|
||||
if source_handle in self.sources:
|
||||
ind = self.sources.index (source_handle) + 1
|
||||
else:
|
||||
self.sources.append (source_handle)
|
||||
ind = len (self.sources)
|
||||
|
||||
citation += "[%d" % ind
|
||||
comments = ref.get_note ()
|
||||
if comments and comments.find ('\n') == -1:
|
||||
citation += " - %s" % comments.rstrip ('.')
|
||||
|
||||
citation += "]"
|
||||
|
||||
return citation
|
||||
|
||||
def person_name (self, person_handle):
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
primary = person.get_primary_name ()
|
||||
|
||||
name = primary.get_title ()
|
||||
if name:
|
||||
name += ' '
|
||||
|
||||
first = primary.get_first_name ()
|
||||
last = primary.get_surname ()
|
||||
first_replaced = first.replace ('?', '')
|
||||
if first_replaced == '':
|
||||
name += self.title (person)
|
||||
else:
|
||||
name += first
|
||||
|
||||
nick = person.get_nick_name ()
|
||||
if nick:
|
||||
nick = nick.strip ('"')
|
||||
nick = nick.strip()
|
||||
name += ' ("%s")' % nick
|
||||
|
||||
spfx = primary.get_surname_prefix ()
|
||||
if spfx:
|
||||
name += ' ' + spfx
|
||||
|
||||
if last.replace ('?', '') == '':
|
||||
if first_replaced == '':
|
||||
name += _(' (unknown)')
|
||||
else:
|
||||
name += ' ' + last
|
||||
|
||||
suffix = primary.get_suffix ()
|
||||
if suffix:
|
||||
name += ', ' + suffix
|
||||
|
||||
the_type = primary.get_type ()
|
||||
if the_type != 'Birth Name':
|
||||
name += ' (%s)' % const.NameTypesMap.find_value (the_type)
|
||||
|
||||
name += self.cite_sources (primary.get_source_references ())
|
||||
return name
|
||||
|
||||
def married_whom (self, person, from_family, listing_children = 0):
|
||||
gender = person.get_gender ()
|
||||
first_rel = 1
|
||||
ret = ''
|
||||
for family_handle in person.get_family_handle_list ():
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
mother_handle = family.get_mother_handle ()
|
||||
mother = self.database.get_person_from_handle(mother_handle)
|
||||
for spouse_handle in [family.get_father_handle (), mother_handle]:
|
||||
if spouse_handle == person.get_handle() or not spouse_handle:
|
||||
continue
|
||||
spouse = self.database.get_person_from_handle(spouse_handle)
|
||||
|
||||
children = ''
|
||||
childlist = family.get_child_handle_list ()
|
||||
child_count = len (childlist)
|
||||
if ((listing_children or family != from_family) and
|
||||
child_count > 0):
|
||||
if child_count == 1:
|
||||
children = _(', and they had a child named ')
|
||||
else:
|
||||
children += _(', and they had %d children: ') % \
|
||||
child_count
|
||||
|
||||
count = 1
|
||||
for child_handle in childlist:
|
||||
child = self.database.get_person_from_handle(child_handle)
|
||||
children += self.first_name_or_nick (child)
|
||||
children += self.cite_sources (child.get_primary_name ().
|
||||
get_source_references ())
|
||||
children += self.abbrev_born_died (child)
|
||||
if child_count - count > 1:
|
||||
children += ', '
|
||||
elif child_count - count == 1:
|
||||
children += _(' and ')
|
||||
|
||||
count += 1
|
||||
|
||||
relationship = family.get_relationship ()
|
||||
if const.save_frel(relationship) == "Married":
|
||||
marriage = None
|
||||
for event_handle in family.get_event_list():
|
||||
if event_handle:
|
||||
event = self.database.get_event_from_handle(event_handle)
|
||||
if event.get_name() == "Marriage":
|
||||
marriage = event
|
||||
break
|
||||
|
||||
if not first_rel:
|
||||
if gender == gen.lib.Person.FEMALE:
|
||||
ret += _(' She later married %(name)s') % \
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
else:
|
||||
ret += _(' He later married %(name)s') % \
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
|
||||
elif (listing_children or
|
||||
spouse == mother or
|
||||
family != from_family):
|
||||
if gender == gen.lib.Person.FEMALE:
|
||||
ret += _(' She married %(name)s') % \
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
else:
|
||||
ret += _(' He married %(name)s') % \
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
|
||||
if marriage:
|
||||
ret += self.event_info (marriage)
|
||||
else: # Not a marriage
|
||||
if not first_rel:
|
||||
if gender == gen.lib.Person.FEMALE:
|
||||
ret += _(' She later had a relationship with %(name)s') % \
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
else:
|
||||
ret += _(' He later had a relationship with %(name)s') % \
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
else:
|
||||
if gender == gen.lib.Person.FEMALE:
|
||||
ret += _(' She had a relationship with %(name)s') % \
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
else:
|
||||
ret += _(' He had a relationship with %(name)s') % \
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
|
||||
ret += children
|
||||
if ret and not ret.endswith ("."):
|
||||
ret += '.'
|
||||
|
||||
first_rel = 0
|
||||
|
||||
return ret
|
||||
|
||||
def inline_notes (self, person):
|
||||
name_note = person.get_primary_name ().get_note ()
|
||||
if not (name_note == '' or name_note.find ('\n') != -1):
|
||||
return _(' Note about their name: ') + name_note
|
||||
note = person.get_note ()
|
||||
if not (person.get_note_format () != 0 or
|
||||
note == '' or note.find ('\n') != -1):
|
||||
return ' ' + note
|
||||
|
||||
return ''
|
||||
|
||||
def long_details (self, note, paras):
|
||||
para_end = note.find ('\n')
|
||||
if para_end != -1:
|
||||
paras = self.long_details (note[note.find ('\n') + 1:], paras)
|
||||
else:
|
||||
para_end = len (note)
|
||||
|
||||
paras.insert (0, (self.doc.end_paragraph, []))
|
||||
paras.insert (0, (self.doc.write_text, [note[:para_end]]))
|
||||
paras.insert (0, (self.doc.start_paragraph, ['AR-Details']))
|
||||
return paras
|
||||
|
||||
def long_notes (self, person, suppress_children = 0,
|
||||
already_described = []):
|
||||
note = person.get_note ()
|
||||
format = person.get_note_format ()
|
||||
if format != 0:
|
||||
paras = [ (self.doc.write_note, [note, format, 'AR-Details']) ]
|
||||
elif note != '' and note.find ('\n') != -1:
|
||||
paras = self.long_details (note, [])
|
||||
else:
|
||||
paras = []
|
||||
|
||||
names = person.get_alternate_names ()
|
||||
event_ref = person.get_event_ref_list ()
|
||||
addresses = person.get_address_list ()
|
||||
if (len (event_handles) + len (addresses) + len (names)) > 0:
|
||||
paras.append ((self.doc.start_paragraph, ['AR-SubEntry']))
|
||||
paras.append ((self.doc.write_text,
|
||||
[_("More about %(person_name)s:") %
|
||||
{'person_name': self.first_name_or_nick (person)}]))
|
||||
paras.append ((self.doc.end_paragraph, []))
|
||||
|
||||
for name in names:
|
||||
paras.append ((self.doc.start_paragraph, ['AR-Details']))
|
||||
paras.append ((self.doc.write_text,
|
||||
[const.NameTypesMap.find_value(name.get_type ()) +
|
||||
': ' + name.get_regular_name ()]))
|
||||
paras.append ((self.doc.end_paragraph, []))
|
||||
|
||||
for event_ref in [person.get_birth_ref(), person.get_death_ref()]:
|
||||
if not event_ref:
|
||||
continue
|
||||
event = self.database.get_event_from_handle(event_ref.ref)
|
||||
note = event.get_note ()
|
||||
note_format = event.get_note_format ()
|
||||
if note and (note_format != 0):
|
||||
paras.append ((self.doc.write_note, [note, format,
|
||||
'AR-Details']))
|
||||
|
||||
for event_ref in event_refs:
|
||||
if not event_ref:
|
||||
continue
|
||||
event = self.database.get_event_from_handle(event_ref.ref)
|
||||
paras.append ((self.doc.start_paragraph, ['AR-Details']))
|
||||
paras.append ((self.doc.write_text, [self.event_info (event)]))
|
||||
paras.append ((self.doc.end_paragraph, []))
|
||||
note = event.get_note ()
|
||||
note_format = event.get_note_format ()
|
||||
if note and (note_format != 0):
|
||||
paras.append ((self.doc.write_note, [note, format,
|
||||
'AR-Details']))
|
||||
|
||||
for address in addresses:
|
||||
paras.append ((self.doc.start_paragraph, ['AR-Details']))
|
||||
paras.append ((self.doc.write_text, [self.address_info (address)]))
|
||||
paras.append ((self.doc.end_paragraph, []))
|
||||
|
||||
return paras
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class ComprehensiveAncestorsOptions(ReportOptions):
|
||||
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
|
||||
def __init__(self,name,person_id=None):
|
||||
ReportOptions.__init__(self,name,person_id)
|
||||
|
||||
# Options specific for this report
|
||||
self.options_dict = {
|
||||
'cites' : 1,
|
||||
}
|
||||
self.options_help = {
|
||||
'cites' : ("=0/1","Whether to cite sources.",
|
||||
["Do not cite sources","Cite sources"],
|
||||
True),
|
||||
}
|
||||
|
||||
def enable_options(self):
|
||||
# Semi-common options that should be enabled for this report
|
||||
self.enable_dict = {
|
||||
'gen' : 10,
|
||||
'pagebbg' : 0,
|
||||
}
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the Comprehensive Ancestors report."""
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=16,bold=1,italic=1)
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_header_level(1)
|
||||
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
para.set(pad=0.5)
|
||||
para.set_description(_('The style used for the title of the page.'))
|
||||
default_style.add_style("AR-Title",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_header_level(2)
|
||||
para.set(pad=0.5)
|
||||
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
para.set_description(_('The style used for the generation header.'))
|
||||
default_style.add_style("AR-Heading",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(lmargin=1.0,pad=0.25)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("AR-Entry",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle ()
|
||||
para.set_description(_('Text style for missing photo.'))
|
||||
default_style.add_style("AR-NoPhotoText", para)
|
||||
|
||||
details_font = BaseDoc.FontStyle()
|
||||
details_font.set(face=BaseDoc.FONT_SANS_SERIF,size=8,italic=1)
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(lmargin=2.7,pad=0,font = details_font)
|
||||
para.set_description(_('Style for details about a person.'))
|
||||
default_style.add_style("AR-Details",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(lmargin=2.5,pad=0.25)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
para.set_header_level (4)
|
||||
default_style.add_style("AR-SubEntry",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(pad=0.05)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("AR-Endnotes",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(lmargin=1.0,pad=0.05)
|
||||
para.set_description(_('Introduction to the children.'))
|
||||
para.set_header_level (3)
|
||||
default_style.add_style("AR-ChildTitle",para)
|
||||
|
||||
def add_user_options(self,dialog):
|
||||
"""
|
||||
Override the base class add_user_options task to add a menu that allows
|
||||
the user to select the sort method.
|
||||
"""
|
||||
|
||||
self.cb_cite = gtk.CheckButton (_("Cite sources"))
|
||||
self.cb_cite.set_active (self.options_dict['cites'])
|
||||
dialog.add_option ('', self.cb_cite)
|
||||
|
||||
def parse_user_options(self,dialog):
|
||||
"""
|
||||
Parses the custom options that we have added.
|
||||
"""
|
||||
self.options_dict['cites'] = int(self.cb_cite.get_active ())
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
register_report(
|
||||
name = 'ancestors_report',
|
||||
category = CATEGORY_TEXT,
|
||||
report_class = ComprehensiveAncestorsReport,
|
||||
options_class = ComprehensiveAncestorsOptions,
|
||||
modes = MODE_GUI | MODE_BKI | MODE_CLI,
|
||||
translated_name = _("Comprehensive Ancestors Report"),
|
||||
status = _("Beta"),
|
||||
description= _("Produces a detailed ancestral report."),
|
||||
author_name="Tim Waugh",
|
||||
author_email="twaugh@redhat.com",
|
||||
unsupported=True
|
||||
)
|
@ -1,419 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"Generate files/Descendant Report"
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# standard python modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/GNOME modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from PluginUtils import register_report
|
||||
from ReportBase import Report, ReportUtils, ReportOptions, \
|
||||
CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
|
||||
pt2cm = ReportUtils.pt2cm
|
||||
import BaseDoc
|
||||
from SubstKeywords import SubstKeywords
|
||||
import Errors
|
||||
from BasicUtils import name_displayer
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_BORN = _('b.')
|
||||
_DIED = _('d.')
|
||||
_sep = 0.5
|
||||
|
||||
class GraphLayout:
|
||||
|
||||
def __init__(self,database,plist,person_handle):
|
||||
self.database = database
|
||||
self.plist = plist
|
||||
self.person_handle = person_handle
|
||||
self.v = []
|
||||
self.e = []
|
||||
self.maxx = 0
|
||||
self.maxy = 0
|
||||
|
||||
def max_size(self):
|
||||
return (self.maxx,self.maxy)
|
||||
|
||||
def layout(self):
|
||||
return ([],[])
|
||||
|
||||
class DescendLine(GraphLayout):
|
||||
|
||||
def layout(self):
|
||||
self.elist = [(0,0)]
|
||||
try:
|
||||
self.space_for(self.person_handle)
|
||||
except RuntimeError,msg:
|
||||
person = self.database.get_person_from_handle(self.person_handle)
|
||||
raise Errors.DatabaseError(
|
||||
_("Database error: %s is defined as his or her own ancestor") %
|
||||
name_displayer.display(person))
|
||||
|
||||
return (self.v,self.e[1:])
|
||||
|
||||
def space_for(self,person_handle,level=1.0,pos=1.0):
|
||||
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
|
||||
last = self.elist[-1]
|
||||
self.elist.append((level,pos))
|
||||
self.e.append((last[0],last[1],level,pos))
|
||||
self.v.append((person_handle,level,pos))
|
||||
if level > self.maxx:
|
||||
self.maxx = level
|
||||
if pos > self.maxy:
|
||||
self.maxy = pos
|
||||
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
for child_handle in family.get_child_handle_list():
|
||||
self.space_for(child_handle,level+1.0,pos)
|
||||
pos = pos + max(self.depth(child_handle),1)
|
||||
if pos > self.maxy:
|
||||
self.maxy = pos
|
||||
self.elist.pop()
|
||||
|
||||
def depth(self,person_handle,val=0):
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
clist = family.get_child_handle_list()
|
||||
val = val + len(clist)
|
||||
for child_handle in clist:
|
||||
d = self.depth(child_handle)
|
||||
if d > 0:
|
||||
val = val + d - 1 #first child is always on the same
|
||||
return val #row as the parent, so subtract 1
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# DescendantGraph
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class DescendantGraph(Report):
|
||||
|
||||
def __init__(self,database,person,options_class):
|
||||
"""
|
||||
Creates DescendantGraph object that produces the report.
|
||||
|
||||
The arguments are:
|
||||
|
||||
database - the GRAMPS database instance
|
||||
person - currently selected person
|
||||
options_class - instance of the Options class for this report
|
||||
|
||||
This report needs the following parameters (class variables)
|
||||
that come in the options class.
|
||||
|
||||
dispf - Display format for the output box.
|
||||
"""
|
||||
Report.__init__(self,database,person,options_class)
|
||||
|
||||
self.display = options_class.handler.options_dict['dispf']
|
||||
|
||||
self.map = {}
|
||||
self.text = {}
|
||||
|
||||
self.box_width = 0
|
||||
self.height = 0
|
||||
self.lines = 0
|
||||
|
||||
plist = self.database.get_person_handles(sort_handles=False)
|
||||
self.layout = DescendLine(self.database,plist,person.get_handle())
|
||||
(self.v,self.e) = self.layout.layout()
|
||||
|
||||
self.text = {}
|
||||
for (p_id,x,y) in self.v:
|
||||
|
||||
self.text[p_id] = []
|
||||
subst = SubstKeywords(self.database,p_id)
|
||||
for line in self.display:
|
||||
self.text[p_id].append(subst.replace(line))
|
||||
|
||||
self.font = self.doc.style_list["DG-Normal"].get_font()
|
||||
for line in self.text[p_id]:
|
||||
new_width = self.doc.string_width(self.font,line)
|
||||
self.box_width = max(self.box_width,new_width)
|
||||
|
||||
self.lines = max(self.lines,len(self.text[p_id]))
|
||||
self.calc()
|
||||
|
||||
def write_report(self):
|
||||
|
||||
maxx,maxy = self.layout.max_size()
|
||||
|
||||
maxx = int(maxx)
|
||||
maxy = int(maxy)
|
||||
|
||||
cols = ((maxx-1)/self.maxx)
|
||||
rows = ((maxy-1)/self.maxy)
|
||||
|
||||
self.pg = []
|
||||
self.ln = []
|
||||
|
||||
for i in range(rows+1):
|
||||
self.pg.append([None]*(cols+1))
|
||||
self.ln.append([None]*(cols+1))
|
||||
|
||||
for (p_id,x,y) in self.v:
|
||||
r = int((y-1)/self.maxy)
|
||||
c = int((x-1)/self.maxx)
|
||||
|
||||
nx = x - (self.maxx)*c
|
||||
ny = y - (self.maxy)*r
|
||||
l = self.pg[r]
|
||||
if l[c] == None:
|
||||
l[c] = [(p_id,nx,ny)]
|
||||
else:
|
||||
l[c].append((p_id,nx,ny))
|
||||
|
||||
for (x1,y1,x2,y2) in self.e:
|
||||
r1 = int((y1-1)/self.maxy)
|
||||
c1 = int((x1-1)/self.maxx)
|
||||
r2 = int((y2-1)/self.maxy)
|
||||
c2 = int((x2-1)/self.maxx)
|
||||
|
||||
nx1 = x1 - (self.maxx)*c1
|
||||
nx2 = x2 - (self.maxx)*c2
|
||||
ny1 = y1 - (self.maxy)*r1
|
||||
ny2 = y2 - (self.maxy)*r2
|
||||
if r1 == r2:
|
||||
if c1 == c2:
|
||||
l = self.ln[r1][c1]
|
||||
if l == None:
|
||||
self.ln[r1][c1] = [(nx1,ny1,nx2,ny2)]
|
||||
else:
|
||||
l.append((nx1,ny1,nx2,ny2))
|
||||
else:
|
||||
l1 = self.ln[r1][c1]
|
||||
l2 = self.ln[r2][c2]
|
||||
if l1 == None:
|
||||
self.ln[r1][c1] = [(nx1,ny1,-nx2,ny2)]
|
||||
else:
|
||||
l1.append((nx1,ny1,-nx2,ny2))
|
||||
if l2 == None:
|
||||
self.ln[r2][c2] = [(-nx2,ny2,nx2,ny2)]
|
||||
else:
|
||||
l2.append((-nx2,ny2,nx2,ny2))
|
||||
|
||||
for c in range(c1+1,c2):
|
||||
if self.ln[r1][c]:
|
||||
self.ln[r1][c].append((nx1,-ny1,nx2,-ny2))
|
||||
else:
|
||||
self.ln[r1][c] = [(nx1,-ny1,nx2,-ny2)]
|
||||
else:
|
||||
if c1 == c2:
|
||||
l1 = self.ln[r1][c1]
|
||||
l2 = self.ln[r2][c2]
|
||||
if l1 == None:
|
||||
self.ln[r1][c1] = [(nx1,ny1,nx2,-ny2)]
|
||||
else:
|
||||
l1.append((nx1,ny1,nx2,-ny2))
|
||||
if l2 == None:
|
||||
self.ln[r2][c2] = [(nx1,-ny2,nx2,ny2)]
|
||||
else:
|
||||
l2.append((nx1,-ny2,nx2,ny2))
|
||||
for r in range(r1+1,r2):
|
||||
if self.ln[r][c1]:
|
||||
self.ln[r][c1].append((nx1,-ny1,nx2,-ny2))
|
||||
else:
|
||||
self.ln[r][c1] = [(nx1,-ny1,nx2,-ny2)]
|
||||
else:
|
||||
l1 = self.ln[r1][c1]
|
||||
l2 = self.ln[r2][c2]
|
||||
l3 = self.ln[r2][c1]
|
||||
|
||||
if l1 == None:
|
||||
self.ln[r1][c1] = [(nx1,ny1,-nx2,-ny2)]
|
||||
else:
|
||||
l1.append((nx1,ny1,-nx2,-ny2))
|
||||
|
||||
if l2 == None:
|
||||
self.ln[r2][c2] = [(-nx1,ny2,nx2,ny2)]
|
||||
else:
|
||||
l2.append((-nx1,ny2,nx2,ny2))
|
||||
|
||||
if l3 == None:
|
||||
self.ln[r2][c1] = [(nx1,-ny2,-nx2,ny2)]
|
||||
else:
|
||||
l3.append((nx1,-ny2,-nx2,ny2))
|
||||
|
||||
for r in range(len(self.pg)):
|
||||
for c in range(len(self.pg[r])):
|
||||
self.print_page(self.pg[r][c],self.ln[r][c],r,c)
|
||||
|
||||
def calc(self):
|
||||
"""calc - calculate the maximum width that a box needs to be. From
|
||||
that and the page dimensions, calculate the proper place to put
|
||||
the elements on a page."""
|
||||
self.height = self.lines*pt2cm(1.25*self.font.get_size())
|
||||
self.box_width = pt2cm(self.box_width+20)
|
||||
|
||||
self.maxx = int(self.doc.get_usable_width()/(self.box_width+_sep))
|
||||
self.maxy = int(self.doc.get_usable_height()/(self.height+_sep))
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_height(self.height)
|
||||
g.set_width(self.box_width)
|
||||
g.set_paragraph_style("DG-Normal")
|
||||
g.set_shadow(1)
|
||||
self.doc.add_draw_style("box",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
self.doc.add_draw_style("line",g)
|
||||
|
||||
def print_page(self, plist,elist,r,c):
|
||||
self.doc.start_page()
|
||||
|
||||
delta = self.doc.get_usable_width()/(self.maxx)
|
||||
top = 0
|
||||
bottom = self.doc.get_usable_height()
|
||||
left = 0
|
||||
right = self.doc.get_usable_width() - (2*_sep)
|
||||
|
||||
if plist:
|
||||
for (p_id,x,y) in plist:
|
||||
name = '\n'.join(self.text[p_id])
|
||||
x = (x-1)*delta + left + _sep
|
||||
y = (y-1)*(self.height+_sep)+top
|
||||
self.doc.draw_box("box",name,x,y)
|
||||
if elist:
|
||||
for (x1,y1,x2,y2) in elist:
|
||||
if x1 < 0:
|
||||
nx1 = left
|
||||
else:
|
||||
nx1 = (x1-1) * delta + left + self.box_width + _sep
|
||||
if x2 < 0:
|
||||
nx2 = right + _sep
|
||||
else:
|
||||
nx2 = (x2-1) * delta + left + _sep
|
||||
if y1 < 0:
|
||||
ny1 = top
|
||||
else:
|
||||
ny1 = (y1-1)*(self.height+_sep)+ top + self.height/2.0
|
||||
if y2 < 0:
|
||||
ny2 = bottom
|
||||
else:
|
||||
ny2 = (y2-1)*(self.height+_sep) + top + self.height/2.0
|
||||
if y1 < 0 and y2 < 0:
|
||||
half = (nx1+nx2)/2.0
|
||||
self.doc.draw_line("line",half,ny1,half,ny2)
|
||||
elif ny1 != ny2:
|
||||
if x1 == -x2:
|
||||
self.doc.draw_line("line",nx1,ny1,nx2,ny2)
|
||||
else:
|
||||
half = (nx1+nx2)/2.0
|
||||
if y1 > 0:
|
||||
self.doc.draw_line("line",nx1,ny1,half,ny1)
|
||||
self.doc.draw_line("line",half,ny1,half,ny2)
|
||||
if y2 > 0:
|
||||
self.doc.draw_line("line",half,ny2,nx2,ny2)
|
||||
else:
|
||||
self.doc.draw_line("line",nx1,ny1,nx2,ny2)
|
||||
|
||||
y = bottom + (self.doc.get_bottom_margin()/2.0)
|
||||
if r or c:
|
||||
self.doc.write_at("DG-Normal","(%d,%d)" % (r,c), right, y)
|
||||
self.doc.end_page()
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class DescendantGraphOptions(ReportOptions):
|
||||
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
|
||||
def __init__(self,name,person_id=None):
|
||||
ReportOptions.__init__(self,name,person_id)
|
||||
|
||||
def enable_options(self):
|
||||
# Semi-common options that should be enabled for this report
|
||||
self.enable_dict = {
|
||||
'dispf' : [ "$n", "%s $b" % _BORN, "%s $d" % _DIED ],
|
||||
}
|
||||
|
||||
def get_textbox_info(self):
|
||||
"""Label the textbox and provide the default contents."""
|
||||
return (_("Display Format"), self.options_dict['dispf'],
|
||||
_("Allows you to customize the data in the boxes in the report"))
|
||||
|
||||
def add_user_options(self,dialog):
|
||||
"""
|
||||
Override the base class add_user_options task to add a menu that allows
|
||||
the user to select the sort method.
|
||||
"""
|
||||
dialog.get_report_extra_textbox_info = self.get_textbox_info
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the Descendant Graph report."""
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(9)
|
||||
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(f)
|
||||
p.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("DG-Normal",p)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
register_report(
|
||||
name = 'descendant_graph',
|
||||
category = CATEGORY_DRAW,
|
||||
report_class = DescendantGraph,
|
||||
options_class = DescendantGraphOptions,
|
||||
modes = MODE_GUI | MODE_BKI | MODE_CLI,
|
||||
translated_name = _("Descendant Graph"),
|
||||
status = _("Stable"),
|
||||
author_name = "Donald N. Allingham",
|
||||
author_email = "don@gramps-project.org",
|
||||
description = _("Generates a graph of descendants of the active person"),
|
||||
unsupported = True,
|
||||
)
|
@ -1,429 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2003-2006 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# python modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import os
|
||||
import cStringIO
|
||||
from gettext import gettext as _
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import BaseDoc
|
||||
import gen.lib
|
||||
import DateHandler
|
||||
import const
|
||||
from PluginUtils import register_report
|
||||
from ReportBase import Report, ReportUtils, ReportOptions, \
|
||||
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# AncestorReport
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class FtmAncestorReport(Report):
|
||||
|
||||
def __init__(self,database,person,options_class):
|
||||
"""
|
||||
Creates the Ftm-Style Ancestor object that produces the report.
|
||||
|
||||
The arguments are:
|
||||
|
||||
database - the GRAMPS database instance
|
||||
person - currently selected person
|
||||
options_class - instance of the Options class for this report
|
||||
|
||||
This report needs the following parameters (class variables)
|
||||
that come in the options class.
|
||||
|
||||
gen - Maximum number of generations to include.
|
||||
pagebgg - Whether to include page breaks between generations.
|
||||
"""
|
||||
Report.__init__(self,database,person,options_class)
|
||||
|
||||
self.map = {}
|
||||
|
||||
(self.max_generations,self.pgbrk) \
|
||||
= options_class.get_report_generations()
|
||||
|
||||
self.sref_map = {}
|
||||
self.sref_index = 0
|
||||
|
||||
def apply_filter(self,person_handle,index,generation=1):
|
||||
if not person_handle or generation >= self.max_generations:
|
||||
return
|
||||
self.map[index] = (person_handle,generation)
|
||||
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
family_handle = person.get_main_parents_family_handle()
|
||||
if family_handle:
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
self.apply_filter(family.get_father_handle(),index*2,generation+1)
|
||||
self.apply_filter(family.get_mother_handle(),(index*2)+1,generation+1)
|
||||
|
||||
def write_report(self):
|
||||
|
||||
self.apply_filter(self.start_person.get_handle(),1)
|
||||
|
||||
name = self.start_person.get_primary_name().get_regular_name()
|
||||
self.doc.start_paragraph("FTA-Title")
|
||||
title = _("Ancestors of %s") % name
|
||||
self.doc.write_text(title)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
keys = self.map.keys()
|
||||
keys.sort()
|
||||
old_gen = 0
|
||||
for key in keys :
|
||||
(person_handle,generation) = self.map[key]
|
||||
if old_gen != generation:
|
||||
if self.pgbrk and generation > 1:
|
||||
self.doc.page_break()
|
||||
self.doc.start_paragraph("FTA-Generation")
|
||||
t = _("Generation No. %d") % generation
|
||||
self.doc.write_text(t)
|
||||
self.doc.end_paragraph()
|
||||
old_gen = generation
|
||||
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
pri_name = person.get_primary_name()
|
||||
self.doc.start_paragraph("FTA-Entry","%d." % key)
|
||||
name = pri_name.get_regular_name()
|
||||
self.doc.start_bold()
|
||||
self.doc.write_text(name)
|
||||
self.doc.end_bold()
|
||||
|
||||
text = ReportUtils.born_died_str(self.database,person,
|
||||
self.endnotes,None,"")
|
||||
if text:
|
||||
self.doc.write_text(text)
|
||||
self.doc.write_text(' ')
|
||||
|
||||
death_valid = bool(person.get_death_handle())
|
||||
self.print_parents(person,death_valid)
|
||||
self.print_spouse(person)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
self.print_notes(person)
|
||||
self.print_more_about(person)
|
||||
|
||||
self.write_endnotes()
|
||||
|
||||
def write_endnotes(self):
|
||||
keys = self.sref_map.keys()
|
||||
if not keys:
|
||||
return
|
||||
|
||||
self.doc.start_paragraph('FTA-Generation')
|
||||
self.doc.write_text(_('Endnotes'))
|
||||
self.doc.end_paragraph()
|
||||
|
||||
keys.sort()
|
||||
for key in keys:
|
||||
srcref = self.sref_map[key]
|
||||
base = self.database.get_source_from_handle(
|
||||
srcref.get_reference_handle())
|
||||
|
||||
self.doc.start_paragraph('FTA-Endnotes',"%d." % key)
|
||||
self.doc.write_text(base.get_title())
|
||||
|
||||
for item in [ base.get_author(), base.get_publication_info(),
|
||||
base.get_abbreviation(),
|
||||
DateHandler.get_date(srcref),]:
|
||||
if item:
|
||||
self.doc.write_text('; %s' % item)
|
||||
|
||||
item = srcref.get_text()
|
||||
if item:
|
||||
self.doc.write_text('; ')
|
||||
self.doc.write_text(_('Text:'))
|
||||
self.doc.write_text(' ')
|
||||
self.doc.write_text(item)
|
||||
|
||||
item = srcref.get_note()
|
||||
if item:
|
||||
self.doc.write_text('; ')
|
||||
self.doc.write_text(_('Comments:'))
|
||||
self.doc.write_text(' ')
|
||||
self.doc.write_text(item)
|
||||
|
||||
self.doc.write_text('.')
|
||||
self.doc.end_paragraph()
|
||||
|
||||
def endnotes(self,obj):
|
||||
if not obj:
|
||||
return ""
|
||||
msg = cStringIO.StringIO()
|
||||
slist = obj.get_source_references()
|
||||
if slist:
|
||||
msg.write('<super>')
|
||||
first = 1
|
||||
for ref in slist:
|
||||
if not first:
|
||||
msg.write(',')
|
||||
first = 0
|
||||
ref_base = ref.get_reference_handle()
|
||||
the_key = 0
|
||||
for key in self.sref_map.keys():
|
||||
if ref_base == self.sref_map[key].get_reference_handle():
|
||||
the_key = key
|
||||
break
|
||||
if the_key:
|
||||
msg.write("%d" % the_key)
|
||||
else:
|
||||
self.sref_index += 1
|
||||
self.sref_map[self.sref_index] = ref
|
||||
msg.write("%d" % self.sref_index)
|
||||
msg.write('</super>')
|
||||
value = msg.getvalue()
|
||||
msg.close()
|
||||
return value
|
||||
|
||||
def print_notes(self,person):
|
||||
note = person.get_note()
|
||||
if not note.strip():
|
||||
return
|
||||
self.doc.start_paragraph('FTA-SubEntry')
|
||||
self.doc.write_text(_('Notes for %(person)s:') % {
|
||||
'person' : person.get_primary_name().get_regular_name()} )
|
||||
self.doc.end_paragraph()
|
||||
format = person.get_note_format()
|
||||
self.doc.write_note(note,format,'FTA-Details')
|
||||
|
||||
def print_more_about(self,person):
|
||||
|
||||
first = 1
|
||||
ncount = 0
|
||||
for name in person.get_alternate_names():
|
||||
if first:
|
||||
self.doc.start_paragraph('FTA-SubEntry')
|
||||
self.doc.write_text(_('More about %(person_name)s:') % {
|
||||
'person_name' : person.get_primary_name().get_regular_name() })
|
||||
self.doc.end_paragraph()
|
||||
first = 0
|
||||
self.doc.start_paragraph('FTA-Details')
|
||||
self.doc.write_text(_('Name %(count)d: %(name)s%(endnotes)s') % {
|
||||
'count' : ncount, 'name' : name.get_regular_name(),
|
||||
'endnotes' : self.endnotes(name),
|
||||
})
|
||||
self.doc.end_paragraph()
|
||||
ncount += 1
|
||||
|
||||
for event_handle in person.get_event_list():
|
||||
event = self.database.get_event_from_handle(event_handle)
|
||||
date = DateHandler.get_date(event)
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = self.database.get_place_from_handle(place_handle).get_title()
|
||||
else:
|
||||
place = u''
|
||||
|
||||
if not date and not place_handle:
|
||||
continue
|
||||
if first:
|
||||
self.doc.start_paragraph('FTA-SubEntry')
|
||||
name = person.get_primary_name().get_regular_name()
|
||||
self.doc.write_text(_('More about %(person_name)s:') % {
|
||||
'person_name' : name })
|
||||
self.doc.end_paragraph()
|
||||
first = 0
|
||||
|
||||
self.doc.start_paragraph('FTA-Details')
|
||||
if date and place:
|
||||
self.doc.write_text(_('%(event_name)s: %(date)s, %(place)s%(endnotes)s. ') % {
|
||||
'event_name' : _(event.get_name()),
|
||||
'date' : date,
|
||||
'endnotes' : self.endnotes(event),
|
||||
'place' : place })
|
||||
elif date:
|
||||
self.doc.write_text(_('%(event_name)s: %(date)s%(endnotes)s. ') % {
|
||||
'event_name' : _(event.get_name()),
|
||||
'endnotes' : self.endnotes(event),
|
||||
'date' : date})
|
||||
else:
|
||||
self.doc.write_text(_('%(event_name)s: %(place)s%(endnotes)s. ') % {
|
||||
'event_name' : _(event.get_name()),
|
||||
'endnotes' : self.endnotes(event),
|
||||
'place' : place })
|
||||
if event.get_description():
|
||||
self.doc.write_text(event.get_description())
|
||||
self.doc.end_paragraph()
|
||||
|
||||
def print_spouse(self,person):
|
||||
family_list = person.get_family_handle_list()
|
||||
if not family_list:
|
||||
return
|
||||
family_handle = family_list[0]
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
if family.get_father_handle() == person.get_handle():
|
||||
spouse_id = family.get_mother_handle()
|
||||
else:
|
||||
spouse_id = family.get_father_handle()
|
||||
if not spouse_id:
|
||||
return
|
||||
spouse = self.database.get_person_from_handle(spouse_id)
|
||||
spouse_name = spouse.get_primary_name().get_regular_name()
|
||||
|
||||
for event_handle in family.get_event_list():
|
||||
if event_handle:
|
||||
event = self.database.get_event_from_handle(event_handle)
|
||||
if event.get_name() == "Marriage":
|
||||
break
|
||||
else:
|
||||
return
|
||||
|
||||
date = DateHandler.get_date(event)
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = self.database.get_place_from_handle(place_handle).get_title()
|
||||
else:
|
||||
place = u''
|
||||
|
||||
if not event:
|
||||
return
|
||||
|
||||
text = ReportUtils.married_str(self.database,person,spouse,event,
|
||||
self.endnotes)
|
||||
if text:
|
||||
self.doc.write_text(text)
|
||||
self.doc.write_text(' ')
|
||||
|
||||
text = ReportUtils.born_died_str(self.database,spouse,
|
||||
self.endnotes,"",0)
|
||||
if text:
|
||||
self.doc.write_text(text)
|
||||
self.doc.write_text(' ')
|
||||
|
||||
death_valid = bool(spouse.get_death_handle())
|
||||
self.print_parents(spouse,death_valid)
|
||||
|
||||
def print_parents(self,person,dead):
|
||||
family_handle = person.get_main_parents_family_handle()
|
||||
if family_handle:
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
mother_handle = family.get_mother_handle()
|
||||
father_handle = family.get_father_handle()
|
||||
if mother_handle:
|
||||
mother = self.database.get_person_from_handle(mother_handle)
|
||||
mother_name = mother.get_primary_name().get_regular_name()
|
||||
else:
|
||||
mother_name = ""
|
||||
if father_handle:
|
||||
father = self.database.get_person_from_handle(father_handle)
|
||||
father_name = father.get_primary_name().get_regular_name()
|
||||
else:
|
||||
father_name = ""
|
||||
|
||||
text = ReportUtils.child_str(person,
|
||||
father_name,mother_name,dead)
|
||||
if text:
|
||||
self.doc.write_text(text)
|
||||
self.doc.write_text(' ')
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class FtmAncestorOptions(ReportOptions):
|
||||
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
|
||||
def __init__(self,name,person_id=None):
|
||||
ReportOptions.__init__(self,name,person_id)
|
||||
|
||||
def enable_options(self):
|
||||
# Semi-common options that should be enabled for this report
|
||||
self.enable_dict = {
|
||||
'gen' : 10,
|
||||
'pagebbg' : 0,
|
||||
}
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the FTM Style Ancestor report."""
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=16,bold=1,italic=1)
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_header_level(1)
|
||||
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
para.set(pad=0.5)
|
||||
para.set_description(_('The style used for the title of the page.'))
|
||||
default_style.add_style("FTA-Title",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_header_level(2)
|
||||
para.set(pad=0.5)
|
||||
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
para.set_description(_('The style used for the generation header.'))
|
||||
default_style.add_style("FTA-Generation",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(first_indent=-1.0,lmargin=1.0,pad=0.25)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("FTA-Entry",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(lmargin=1.0,pad=0.05)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("FTA-Details",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(lmargin=1.0,pad=0.25)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("FTA-SubEntry",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(pad=0.05)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("FTA-Endnotes",para)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
register_report(
|
||||
name = 'ftm_ancestor_report',
|
||||
category = CATEGORY_TEXT,
|
||||
report_class = FtmAncestorReport,
|
||||
options_class = FtmAncestorOptions,
|
||||
modes = MODE_GUI | MODE_BKI | MODE_CLI,
|
||||
translated_name = _("FTM Style Ancestor Report"),
|
||||
status=(_("Beta")),
|
||||
description= _("Produces a textual ancestral report similar to Family Tree Maker."),
|
||||
author_name="Donald N. Allingham",
|
||||
author_email="dallingham@users.sourceforge.net",
|
||||
unsupported=True
|
||||
)
|
@ -1,577 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2003-2006 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
# Written by Alex Roitman, largely based on the FtmStyleAncestors.py
|
||||
# report by Don Allingham
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# python modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import os
|
||||
import cStringIO
|
||||
from gettext import gettext as _
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from PluginUtils import register_report
|
||||
from ReportBase import Report, ReportUtils, ReportOptions, \
|
||||
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
import BaseDoc
|
||||
import gen.lib
|
||||
import DateHandler
|
||||
import const
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# DescendantReport
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class FtmDescendantReport(Report):
|
||||
|
||||
def __init__(self,database,person,options_class):
|
||||
"""
|
||||
Creates the Ftm-Style Descendant object that produces the report.
|
||||
|
||||
The arguments are:
|
||||
|
||||
database - the GRAMPS database instance
|
||||
person - currently selected person
|
||||
options_class - instance of the Options class for this report
|
||||
|
||||
This report needs the following parameters (class variables)
|
||||
that come in the options class.
|
||||
|
||||
gen - Maximum number of generations to include.
|
||||
pagebbg - Whether to include page breaks between generations.
|
||||
"""
|
||||
|
||||
Report.__init__(self,database,person,options_class)
|
||||
|
||||
self.anc_map = {}
|
||||
self.gen_map = {}
|
||||
|
||||
(self.max_generations,self.pgbrk) \
|
||||
= options_class.get_report_generations()
|
||||
|
||||
self.sref_map = {}
|
||||
self.sref_index = 0
|
||||
|
||||
def define_table_styles(self):
|
||||
tbl = BaseDoc.TableStyle()
|
||||
tbl.set_width(100)
|
||||
tbl.set_columns(3)
|
||||
tbl.set_column_width(0,10)
|
||||
tbl.set_column_width(1,5)
|
||||
tbl.set_column_width(2,85)
|
||||
self.doc.add_table_style('FTD-ChildTable',tbl)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
self.doc.add_cell_style('FTD-Normal',cell)
|
||||
|
||||
def apply_filter(self,person_handle,index,generation=1):
|
||||
|
||||
if (not person_handle) or (generation > self.max_generations):
|
||||
return
|
||||
|
||||
self.anc_map[index] = person_handle
|
||||
try:
|
||||
self.gen_map[generation].append(index)
|
||||
except:
|
||||
self.gen_map[generation] = []
|
||||
self.gen_map[generation].append(index)
|
||||
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
for child_handle in family.get_child_handle_list():
|
||||
ix = max(self.anc_map.keys())
|
||||
self.apply_filter(child_handle,ix+1,generation+1)
|
||||
|
||||
|
||||
def write_report(self):
|
||||
|
||||
self.apply_filter(self.start_person.get_handle(),1)
|
||||
|
||||
name = self.start_person.get_primary_name().get_regular_name()
|
||||
self.doc.start_paragraph("FTD-Title")
|
||||
title = _("Descendants of %s") % name
|
||||
self.doc.write_text(title)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
generations = self.gen_map.keys()
|
||||
generations.sort()
|
||||
|
||||
for generation in generations:
|
||||
if self.pgbrk and generation > 1:
|
||||
self.doc.page_break()
|
||||
self.doc.start_paragraph("FTD-Generation")
|
||||
t = _("Generation No. %d") % generation
|
||||
self.doc.write_text(t)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
indexlist = self.gen_map[generation]
|
||||
indexlist.sort()
|
||||
for key in indexlist:
|
||||
person_handle = self.anc_map[key]
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
|
||||
self.doc.start_paragraph("FTD-Entry","%d." % key)
|
||||
name = person.get_primary_name().get_regular_name()
|
||||
self.doc.start_bold()
|
||||
self.doc.write_text(name)
|
||||
self.doc.end_bold()
|
||||
|
||||
text = ReportUtils.born_died_str(self.database,person,
|
||||
self.endnotes,None,"")
|
||||
if text:
|
||||
self.doc.write_text(text)
|
||||
self.doc.write_text(' ')
|
||||
|
||||
death_valid = bool(person.get_death_handle())
|
||||
self.print_parents(person,death_valid)
|
||||
self.print_spouse(person)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
self.print_notes(person)
|
||||
self.print_more_about(person)
|
||||
self.print_more_about_families(person)
|
||||
if generation < self.max_generations:
|
||||
self.print_children(person)
|
||||
|
||||
self.write_endnotes()
|
||||
|
||||
def write_endnotes(self):
|
||||
keys = self.sref_map.keys()
|
||||
if not keys:
|
||||
return
|
||||
|
||||
self.doc.start_paragraph('FTD-Generation')
|
||||
self.doc.write_text(_('Endnotes'))
|
||||
self.doc.end_paragraph()
|
||||
|
||||
keys.sort()
|
||||
for key in keys:
|
||||
srcref = self.sref_map[key]
|
||||
base_handle = srcref.get_reference_handle()
|
||||
base = self.database.get_source_from_handle(base_handle)
|
||||
|
||||
self.doc.start_paragraph('FTD-Endnotes',"%d." % key)
|
||||
self.doc.write_text(base.get_title())
|
||||
|
||||
for item in [ base.get_author(), base.get_publication_info(),
|
||||
base.get_abbreviation(),
|
||||
DateHandler.get_date(srcref),]:
|
||||
if item:
|
||||
self.doc.write_text('; %s' % item)
|
||||
|
||||
item = srcref.get_text()
|
||||
if item:
|
||||
self.doc.write_text('; ')
|
||||
self.doc.write_text(_('Text:'))
|
||||
self.doc.write_text(' ')
|
||||
self.doc.write_text(item)
|
||||
|
||||
item = srcref.get_note()
|
||||
if item:
|
||||
self.doc.write_text('; ')
|
||||
self.doc.write_text(_('Comments:'))
|
||||
self.doc.write_text(' ')
|
||||
self.doc.write_text(item)
|
||||
|
||||
self.doc.write_text('.')
|
||||
self.doc.end_paragraph()
|
||||
|
||||
def endnotes(self,obj):
|
||||
if not obj:
|
||||
return ""
|
||||
msg = cStringIO.StringIO()
|
||||
slist = obj.get_source_references()
|
||||
if slist:
|
||||
msg.write('<super>')
|
||||
first = 1
|
||||
for ref in slist:
|
||||
if not first:
|
||||
msg.write(',')
|
||||
first = 0
|
||||
ref_base = ref.get_reference_handle()
|
||||
the_key = 0
|
||||
for key in self.sref_map.keys():
|
||||
if ref_base == self.sref_map[key].get_reference_handle():
|
||||
the_key = key
|
||||
break
|
||||
if the_key:
|
||||
msg.write("%d" % the_key)
|
||||
else:
|
||||
self.sref_index += 1
|
||||
self.sref_map[self.sref_index] = ref
|
||||
msg.write("%d" % self.sref_index)
|
||||
msg.write('</super>')
|
||||
str = msg.getvalue()
|
||||
msg.close()
|
||||
return str
|
||||
|
||||
def print_notes(self,person):
|
||||
note = person.get_note()
|
||||
if not note.strip():
|
||||
return
|
||||
self.doc.start_paragraph('FTD-SubEntry')
|
||||
self.doc.write_text(_('Notes for %(person)s:') % {
|
||||
'person' : person.get_primary_name().get_regular_name()} )
|
||||
self.doc.end_paragraph()
|
||||
format = person.get_note_format()
|
||||
self.doc.write_note(note,format,'FTD-Details')
|
||||
|
||||
def print_more_about(self,person):
|
||||
|
||||
first = 1
|
||||
ncount = 1
|
||||
for name in person.get_alternate_names():
|
||||
if first:
|
||||
self.doc.start_paragraph('FTD-SubEntry')
|
||||
self.doc.write_text(_('More about %(person_name)s:') % {
|
||||
'person_name' : person.get_primary_name().get_regular_name() })
|
||||
self.doc.end_paragraph()
|
||||
first = 0
|
||||
self.doc.start_paragraph('FTD-Details')
|
||||
self.doc.write_text(_('Name %(count)d: %(name)s%(endnotes)s') % {
|
||||
'count' : ncount, 'name' : name.get_regular_name(),
|
||||
'endnotes' : self.endnotes(name),
|
||||
})
|
||||
self.doc.end_paragraph()
|
||||
ncount += 1
|
||||
|
||||
for event_handle in person.get_event_list():
|
||||
if not event_handle:
|
||||
continue
|
||||
event = self.database.get_event_from_handle(event_handle)
|
||||
date = DateHandler.get_date(event)
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = self.database.get_place_from_handle(place_handle)
|
||||
else:
|
||||
place = None
|
||||
|
||||
if not date and not place:
|
||||
continue
|
||||
if first:
|
||||
self.doc.start_paragraph('FTD-SubEntry')
|
||||
name = person.get_primary_name().get_regular_name()
|
||||
self.doc.write_text(_('More about %(person_name)s:') % { 'person_name' : name })
|
||||
self.doc.end_paragraph()
|
||||
first = 0
|
||||
|
||||
self.doc.start_paragraph('FTD-Details')
|
||||
if date and place:
|
||||
self.doc.write_text(_('%(event_name)s: %(date)s, %(place)s%(endnotes)s. ') % {
|
||||
'event_name' : _(event.get_name()),
|
||||
'date' : date,
|
||||
'endnotes' : self.endnotes(event),
|
||||
'place' : place.get_title() })
|
||||
elif date:
|
||||
self.doc.write_text(_('%(event_name)s: %(date)s%(endnotes)s. ') % {
|
||||
'event_name' : _(event.get_name()),
|
||||
'endnotes' : self.endnotes(event),
|
||||
'date' : date})
|
||||
else:
|
||||
self.doc.write_text(_('%(event_name)s: %(place)s%(endnotes)s. ') % {
|
||||
'event_name' : _(event.get_name()),
|
||||
'endnotes' : self.endnotes(event),
|
||||
'place' : place.get_title() })
|
||||
if event.get_description():
|
||||
self.doc.write_text(event.get_description())
|
||||
self.doc.end_paragraph()
|
||||
|
||||
|
||||
def print_more_about_families(self,person):
|
||||
"More about husband and wife"
|
||||
|
||||
first = 1
|
||||
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
father_handle = family.get_father_handle()
|
||||
mother_handle = family.get_mother_handle()
|
||||
if father_handle and mother_handle:
|
||||
husband = self.database.get_person_from_handle(father_handle).get_primary_name().get_regular_name()
|
||||
wife = self.database.get_person_from_handle(mother_handle).get_primary_name().get_regular_name()
|
||||
else:
|
||||
continue
|
||||
for event_handle in family.get_event_list():
|
||||
if not event_handle:
|
||||
continue
|
||||
event = self.database.get_event_from_handle(event_handle)
|
||||
date = DateHandler.get_date(event)
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = self.database.get_place_from_handle(place_handle)
|
||||
else:
|
||||
place = None
|
||||
|
||||
if not date and not place:
|
||||
continue
|
||||
if first:
|
||||
self.doc.start_paragraph('FTD-SubEntry')
|
||||
self.doc.write_text(_('More about %(husband)s and %(wife)s:') % { 'husband' : husband, 'wife' : wife })
|
||||
self.doc.end_paragraph()
|
||||
first = 0
|
||||
|
||||
self.doc.start_paragraph('FTD-Details')
|
||||
if date and place:
|
||||
self.doc.write_text(_('%(event_name)s: %(date)s, %(place)s%(endnotes)s. ') % {
|
||||
'event_name' : _(event.get_name()),
|
||||
'date' : date,
|
||||
'endnotes' : self.endnotes(event),
|
||||
'place' : place.get_title() })
|
||||
elif date:
|
||||
self.doc.write_text(_('%(event_name)s: %(date)s%(endnotes)s. ') % {
|
||||
'event_name' : _(event.get_name()),
|
||||
'endnotes' : self.endnotes(event),
|
||||
'date' : date})
|
||||
else:
|
||||
self.doc.write_text(_('%(event_name)s: %(place)s%(endnotes)s. ') % {
|
||||
'event_name' : _(event.get_name()),
|
||||
'endnotes' : self.endnotes(event),
|
||||
'place' : place.get_title() })
|
||||
if event.get_description():
|
||||
self.doc.write_text(event.get_description())
|
||||
self.doc.end_paragraph()
|
||||
|
||||
|
||||
def print_children(self,person):
|
||||
"Children of such-and-such"
|
||||
|
||||
name = person.get_primary_name().get_regular_name()
|
||||
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
first = 1
|
||||
|
||||
father_handle = family.get_father_handle()
|
||||
mother_handle = family.get_mother_handle()
|
||||
if father_handle == person.get_handle():
|
||||
spouse_id = mother_handle
|
||||
else:
|
||||
spouse_id = father_handle
|
||||
spouse = self.database.get_person_from_handle(spouse_id)
|
||||
|
||||
child_index = 0
|
||||
for child_handle in family.get_child_handle_list():
|
||||
child = self.database.get_person_from_handle(child_handle)
|
||||
child_index = child_index + 1
|
||||
for (ind,p_id) in self.anc_map.items():
|
||||
if p_id == child_handle:
|
||||
index = ind
|
||||
|
||||
if first:
|
||||
first = 0
|
||||
self.doc.start_paragraph('FTD-SubEntry')
|
||||
if spouse:
|
||||
self.doc.write_text(_('Children of %(person_name)s and %(spouse_name)s are:') % {
|
||||
'person_name' : name, 'spouse_name' : spouse.get_primary_name().get_regular_name() })
|
||||
else:
|
||||
self.doc.write_text(_('Children of %(person_name)s are:') % { 'person_name' : name })
|
||||
self.doc.end_paragraph()
|
||||
self.doc.start_table(family.get_handle(),'FTD-ChildTable')
|
||||
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell('FTD-Normal')
|
||||
self.doc.start_paragraph('FTD-Child-Num')
|
||||
self.doc.write_text("%d." % index)
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
|
||||
self.doc.start_cell('FTD-Normal')
|
||||
self.doc.start_paragraph('FTD-Child-Num')
|
||||
self.doc.write_text("%s." % ReportUtils.roman(child_index).lower())
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
|
||||
self.doc.start_cell('FTD-Normal')
|
||||
self.doc.start_paragraph('FTD-Details')
|
||||
|
||||
text = ReportUtils.born_died_str(self.database,child,
|
||||
self.endnotes)
|
||||
self.doc.write_text(text)
|
||||
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
if not first:
|
||||
self.doc.end_table()
|
||||
first = 1
|
||||
|
||||
def print_spouse(self,person):
|
||||
family_list = person.get_family_handle_list()
|
||||
if not family_list:
|
||||
return
|
||||
family_handle = family_list[0]
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
if family.get_father_handle() == person.get_handle():
|
||||
spouse_id = family.get_mother_handle()
|
||||
else:
|
||||
spouse_id = family.get_father_handle()
|
||||
if not spouse_id:
|
||||
return
|
||||
spouse = self.database.get_person_from_handle(spouse_id)
|
||||
|
||||
for event_handle in family.get_event_list():
|
||||
if event_handle:
|
||||
event = self.database.get_event_from_handle(event_handle)
|
||||
if event.get_name() == "Marriage":
|
||||
break
|
||||
else:
|
||||
event = None
|
||||
|
||||
if not event:
|
||||
return
|
||||
|
||||
text = ReportUtils.married_str(self.database,person,spouse,event,
|
||||
self.endnotes)
|
||||
if text:
|
||||
self.doc.write_text(text)
|
||||
self.doc.write_text(' ')
|
||||
|
||||
text = ReportUtils.born_died_str(self.database,spouse,
|
||||
self.endnotes,"",0)
|
||||
if text:
|
||||
self.doc.write_text(text)
|
||||
self.doc.write_text(' ')
|
||||
|
||||
death_valid = bool(spouse.get_death_handle())
|
||||
self.print_parents(spouse,death_valid)
|
||||
|
||||
|
||||
def print_parents(self,person,dead):
|
||||
family_handle = person.get_main_parents_family_handle()
|
||||
if family_handle:
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
mother_handle = family.get_mother_handle()
|
||||
if mother_handle:
|
||||
mother = self.database.get_person_from_handle(mother_handle)
|
||||
mother_name = mother.get_primary_name().get_regular_name()
|
||||
else:
|
||||
mother_name = ""
|
||||
father_handle = family.get_father_handle()
|
||||
if father_handle:
|
||||
father = self.database.get_person_from_handle(father_handle)
|
||||
father_name = father.get_primary_name().get_regular_name()
|
||||
else:
|
||||
father_name = ""
|
||||
|
||||
text = ReportUtils.child_str(person,
|
||||
father_name,mother_name,dead)
|
||||
if text:
|
||||
self.doc.write_text(text)
|
||||
self.doc.write_text(' ')
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class FtmDescendantOptions(ReportOptions):
|
||||
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
|
||||
def __init__(self,name,person_id=None):
|
||||
ReportOptions.__init__(self,name,person_id)
|
||||
|
||||
def enable_options(self):
|
||||
# Semi-common options that should be enabled for this report
|
||||
self.enable_dict = {
|
||||
'gen' : 10,
|
||||
'pagebbg' : 0,
|
||||
}
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the FTM Style Descendant report."""
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=16,bold=1,italic=1)
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_header_level(1)
|
||||
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
para.set(pad=0.5)
|
||||
para.set_description(_('The style used for the title of the page.'))
|
||||
default_style.add_style("FTD-Title",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_header_level(2)
|
||||
para.set(pad=0.5)
|
||||
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
para.set_description(_('The style used for the generation header.'))
|
||||
default_style.add_style("FTD-Generation",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(first_indent=-1.0,lmargin=1.0,pad=0.25)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("FTD-Entry",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(lmargin=1.0,pad=0.05)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("FTD-Details",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(lmargin=0.0,pad=0.05)
|
||||
para.set_description(_('The style used for numbering children.'))
|
||||
default_style.add_style("FTD-Child-Num",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(lmargin=1.0,pad=0.25)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("FTD-SubEntry",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(pad=0.05)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("FTD-Endnotes",para)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
register_report(
|
||||
name = 'ftm_descendant_report',
|
||||
category = CATEGORY_TEXT,
|
||||
report_class = FtmDescendantReport,
|
||||
options_class = FtmDescendantOptions,
|
||||
modes = MODE_GUI | MODE_BKI | MODE_CLI,
|
||||
translated_name = _("FTM Style Descendant Report"),
|
||||
status = _("Beta"),
|
||||
description= _("Produces a textual descendant report similar to Family Tree Maker."),
|
||||
author_name="Alex Roitman",
|
||||
author_email="shura@alex.neuro.umn.edu",
|
||||
unsupported=True
|
||||
)
|
@ -1,397 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"Generate files/Individual Summary"
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# standard python modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import os
|
||||
from gettext import gettext as _
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# GNOME/gtk
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
import const
|
||||
import BaseDoc
|
||||
from PluginUtils import register_report
|
||||
from ReportBase import Report, ReportUtils, ReportOptions, \
|
||||
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
import DateHandler
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# IndivSummary
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class IndivSummary(Report):
|
||||
|
||||
def __init__(self,database,person,options_class):
|
||||
"""
|
||||
Creates the Ftm-Style Descendant object that produces the report.
|
||||
|
||||
The arguments are:
|
||||
|
||||
database - the GRAMPS database instance
|
||||
person - currently selected person
|
||||
options_class - instance of the Options class for this report
|
||||
|
||||
"""
|
||||
|
||||
Report.__init__(self,database,person,options_class)
|
||||
|
||||
def write_fact(self,event):
|
||||
if event == None:
|
||||
return
|
||||
name = const.display_event(event.get_name())
|
||||
date = DateHandler.get_date(event)
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place_obj = self.database.get_place_from_handle(place_handle)
|
||||
place = place_obj.get_title()
|
||||
else:
|
||||
place = ""
|
||||
|
||||
description = event.get_description()
|
||||
if not date:
|
||||
if not place:
|
||||
return
|
||||
else:
|
||||
text = '%s. %s' % (place,description)
|
||||
else:
|
||||
if not place:
|
||||
text = '%s. %s' % (date,description)
|
||||
else:
|
||||
text = _('%(date)s in %(place)s.') % { 'date' : date,
|
||||
'place' : place }
|
||||
text = '%s %s' % (text,description)
|
||||
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell("IVS-NormalCell")
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.write_text(name)
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
|
||||
self.doc.start_cell("IVS-NormalCell")
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.write_text(text)
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def write_families(self):
|
||||
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.end_paragraph()
|
||||
self.doc.start_table("three","IVS-IndTable")
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell("IVS-TableHead",2)
|
||||
self.doc.start_paragraph("IVS-TableTitle")
|
||||
self.doc.write_text(_("Marriages/Children"))
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
for family_handle in self.start_person.get_family_handle_list():
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
if self.start_person.get_handle() == family.get_father_handle():
|
||||
spouse_id = family.get_mother_handle()
|
||||
else:
|
||||
spouse_id = family.get_father_handle()
|
||||
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell("IVS-NormalCell",2)
|
||||
self.doc.start_paragraph("IVS-Spouse")
|
||||
if spouse_id:
|
||||
spouse = self.database.get_person_from_handle(spouse_id)
|
||||
self.doc.write_text(spouse.get_primary_name().get_regular_name())
|
||||
else:
|
||||
self.doc.write_text(_("unknown"))
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
for event_handle in family.get_event_list():
|
||||
event = self.database.get_event_from_handle(event_handle)
|
||||
self.write_fact(event)
|
||||
|
||||
child_list = family.get_child_handle_list()
|
||||
if len(child_list):
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell("IVS-NormalCell")
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.write_text(_("Children"))
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
|
||||
self.doc.start_cell("IVS-ListCell")
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
|
||||
first = 1
|
||||
for child_handle in child_list:
|
||||
if first == 1:
|
||||
first = 0
|
||||
else:
|
||||
self.doc.write_text('\n')
|
||||
child = self.database.get_person_from_handle(child_handle)
|
||||
self.doc.write_text(child.get_primary_name().get_regular_name())
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
self.doc.end_table()
|
||||
|
||||
def write_report(self):
|
||||
|
||||
media_list = self.start_person.get_media_list()
|
||||
|
||||
name = self.start_person.get_primary_name().get_regular_name()
|
||||
self.doc.start_paragraph("IVS-Title")
|
||||
self.doc.write_text(_("Summary of %s") % name)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.end_paragraph()
|
||||
|
||||
if len(media_list) > 0:
|
||||
object_handle = media_list[0].get_reference_handle()
|
||||
object = self.database.get_object_from_handle(object_handle)
|
||||
mime_type = object.get_mime_type()
|
||||
if mime_type and mime_type.startswith("image"):
|
||||
file = object.get_path()
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.add_media_object(file, "center", 4.0, 4.0)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
self.doc.start_table("one","IVS-IndTable")
|
||||
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell("IVS-NormalCell")
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.write_text("%s:" % _("Name"))
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
|
||||
self.doc.start_cell("IVS-NormalCell")
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.write_text(self.start_person.get_primary_name().get_regular_name())
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell("IVS-NormalCell")
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.write_text("%s:" % _("Gender"))
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
|
||||
self.doc.start_cell("IVS-NormalCell")
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
if self.start_person.get_gender() == gen.lib.Person.MALE:
|
||||
self.doc.write_text(_("Male"))
|
||||
else:
|
||||
self.doc.write_text(_("Female"))
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
fam_id = self.start_person.get_main_parents_family_handle()
|
||||
if fam_id:
|
||||
family = self.database.get_family_from_handle(fam_id)
|
||||
father_handle = family.get_father_handle()
|
||||
if father_handle:
|
||||
dad = self.database.get_person_from_handle(father_handle)
|
||||
father = dad.get_primary_name().get_regular_name()
|
||||
else:
|
||||
father = ""
|
||||
mother_handle = family.get_mother_handle()
|
||||
if mother_handle:
|
||||
mom = self.database.get_person_from_handle(mother_handle)
|
||||
mother = mom.get_primary_name().get_regular_name()
|
||||
else:
|
||||
mother = ""
|
||||
else:
|
||||
father = ""
|
||||
mother = ""
|
||||
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell("IVS-NormalCell")
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.write_text("%s:" % _("Father"))
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
|
||||
self.doc.start_cell("IVS-NormalCell")
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.write_text(father)
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell("IVS-NormalCell")
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.write_text("%s:" % _("Mother"))
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
|
||||
self.doc.start_cell("IVS-NormalCell")
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.write_text(mother)
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
self.doc.end_table()
|
||||
|
||||
self.doc.start_paragraph("IVS-Normal")
|
||||
self.doc.end_paragraph()
|
||||
|
||||
self.doc.start_table("two","IVS-IndTable")
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell("IVS-TableHead",2)
|
||||
self.doc.start_paragraph("IVS-TableTitle")
|
||||
self.doc.write_text(_("Individual Facts"))
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
event_ref_list = [ self.start_person.get_birth_ref(),
|
||||
self.start_person.get_death_ref() ] + \
|
||||
self.start_person.get_event_list()
|
||||
for event_ref in event_ref_list:
|
||||
if event_ref:
|
||||
event = self.database.get_event_from_handle(event_ref.ref)
|
||||
self.write_fact(event)
|
||||
self.doc.end_table()
|
||||
|
||||
self.write_families()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class IndivSummaryOptions(ReportOptions):
|
||||
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
|
||||
def __init__(self,name,person_id=None):
|
||||
ReportOptions.__init__(self,name,person_id)
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the Individual Summary Report."""
|
||||
# Paragraph Styles
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
font.set_size(16)
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for the title of the page."))
|
||||
default_style.add_paragraph_style("IVS-Title",p)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
font.set_size(12)
|
||||
font.set_italic(1)
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for category labels."))
|
||||
default_style.add_paragraph_style("IVS-TableTitle",p)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
font.set_size(12)
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for the spouse's name."))
|
||||
default_style.add_paragraph_style("IVS-Spouse",p)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_size(12)
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(font)
|
||||
p.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_paragraph_style("IVS-Normal",p)
|
||||
|
||||
#Table Styles
|
||||
tbl = BaseDoc.TableStyle()
|
||||
tbl.set_width(100)
|
||||
tbl.set_columns(2)
|
||||
tbl.set_column_width(0,20)
|
||||
tbl.set_column_width(1,80)
|
||||
default_style.add_table_style("IVS-IndTable",tbl)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_top_border(1)
|
||||
cell.set_bottom_border(1)
|
||||
default_style.add_cell_style("IVS-TableHead",cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
default_style.add_cell_style("IVS-NormalCell",cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_longlist(1)
|
||||
default_style.add_cell_style("IVS-ListCell",cell)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Register plugins
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
register_report(
|
||||
name = 'individual_summary',
|
||||
category = CATEGORY_TEXT,
|
||||
report_class = IndivSummary,
|
||||
options_class = IndivSummaryOptions,
|
||||
modes = MODE_GUI | MODE_BKI | MODE_CLI,
|
||||
translated_name = _("Individual Summary"),
|
||||
status=(_("Stable")),
|
||||
description=_("Produces a detailed report on the selected person."),
|
||||
author_name="Donald N. Allingham",
|
||||
author_email="don@gramps-project.org",
|
||||
unsupported = True
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user