2007-12-28 15:38:19 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2008-01-12 17:07:21 +05:30
|
|
|
# Copyright (C) 2007-2008 Stephane Charette
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2007-2008 Brian G. Matherly
|
2007-12-28 15:38:19 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Pubilc 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$
|
|
|
|
|
|
|
|
"""
|
|
|
|
Family Lines, a GraphViz-based plugin for Gramps.
|
|
|
|
"""
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
from gettext import gettext as _
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Set up logging
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".FamilyLines")
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS module
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import gen.lib
|
|
|
|
import Utils
|
|
|
|
import ThumbNails
|
|
|
|
from DateHandler import displayer as _dd
|
2008-01-18 11:09:50 +05:30
|
|
|
from ReportBase import Report, ReportUtils, MenuReportOptions, \
|
|
|
|
CATEGORY_GRAPHVIZ, MODE_GUI
|
2008-05-19 00:54:28 +05:30
|
|
|
from PluginUtils import PluginManager, EnumeratedListOption, BooleanOption, \
|
2008-01-18 11:09:50 +05:30
|
|
|
NumberOption, ColourOption, PersonListOption, SurnameColourOption
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-12 13:09:39 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constant options items
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
_COLORS = [ { 'name' : _("B&W outline"), 'value' : "outline" },
|
|
|
|
{ 'name' : _("Coloured outline"), 'value' : "colored" },
|
|
|
|
{ 'name' : _("Colour fill"), 'value' : "filled" }]
|
2007-12-31 11:13:14 +05:30
|
|
|
|
2007-12-28 15:38:19 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# A quick overview of the classes we'll be using:
|
|
|
|
#
|
|
|
|
# class FamilyLinesOptions(MenuReportOptions)
|
|
|
|
# - this class is created when the report dialog comes up
|
|
|
|
# - all configuration controls for the report are created here
|
|
|
|
# - see src/ReportBase/_ReportOptions.py for more information
|
|
|
|
#
|
|
|
|
# class FamilyLinesReport(Report)
|
|
|
|
# - this class is created only after the user clicks on "OK"
|
|
|
|
# - the actual report generation is done by this class
|
|
|
|
# - see src/ReportBase/_Report.py for more information
|
|
|
|
#
|
|
|
|
# Likely to be of additional interest is register_report() at the
|
|
|
|
# very bottom of this file.
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class FamilyLinesOptions(MenuReportOptions):
|
|
|
|
"""
|
|
|
|
Defines all of the controls necessary
|
|
|
|
to configure the FamilyLines reports.
|
|
|
|
"""
|
2008-01-24 18:20:33 +05:30
|
|
|
def __init__(self, name, dbase):
|
2008-01-28 18:55:22 +05:30
|
|
|
self.limit_parents = None
|
|
|
|
self.max_parents = None
|
|
|
|
self.limit_children = None
|
|
|
|
self.max_children = None
|
|
|
|
self.include_images = None
|
|
|
|
self.image_location = None
|
2008-01-24 18:20:33 +05:30
|
|
|
MenuReportOptions.__init__(self, name, dbase)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-01-24 18:20:33 +05:30
|
|
|
def add_menu_options(self, menu):
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# --------------------------------
|
|
|
|
category = _('People of Interest')
|
|
|
|
# --------------------------------
|
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
person_list = PersonListOption(_('People of interest'))
|
|
|
|
person_list.set_help(_('People of interest are used as a starting ' \
|
|
|
|
'point when determining "family lines".'))
|
|
|
|
menu.add_option(category, 'gidlist', person_list)
|
|
|
|
|
|
|
|
followpar = BooleanOption(
|
|
|
|
_('Follow parents to determine family lines'), True)
|
|
|
|
followpar.set_help(_('Parents and their ancestors will be ' \
|
|
|
|
'considered when determining "family lines".'))
|
|
|
|
menu.add_option(category, 'followpar', followpar)
|
|
|
|
|
|
|
|
followchild = BooleanOption(_('Follow children to determine ' \
|
|
|
|
'"family lines"'), True)
|
|
|
|
followchild.set_help(_('Children will be considered when ' \
|
|
|
|
'determining "family lines".'))
|
|
|
|
menu.add_option(category, 'followchild', followchild)
|
|
|
|
|
|
|
|
remove_extra_people = BooleanOption(
|
|
|
|
_('Try to remove extra people and families'), True)
|
|
|
|
remove_extra_people.set_help(_('People and families not directly ' \
|
|
|
|
'related to people of interest will ' \
|
|
|
|
'be removed when determining ' \
|
|
|
|
'"family lines".'))
|
|
|
|
menu.add_option(category, 'removeextra', remove_extra_people)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# ----------------------------
|
|
|
|
category = _('Family Colours')
|
|
|
|
# ----------------------------
|
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
surname_color = SurnameColourOption(_('Family colours'))
|
|
|
|
surname_color.set_help(_('Colours to use for various family lines.'))
|
|
|
|
menu.add_option(category, 'surnamecolors', surname_color)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# -------------------------
|
|
|
|
category = _('Individuals')
|
|
|
|
# -------------------------
|
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
color_males = ColourOption(_('Males'), '#e0e0ff')
|
|
|
|
color_males.set_help(_('The colour to use to display men.'))
|
|
|
|
menu.add_option(category, 'colormales', color_males)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
color_females = ColourOption(_('Females'), '#ffe0e0')
|
|
|
|
color_females.set_help(_('The colour to use to display women.'))
|
|
|
|
menu.add_option(category, 'colorfemales', color_females)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
color_unknown = ColourOption(_('Unknown'), '#e0e0e0')
|
|
|
|
color_unknown.set_help(_('The colour to use when the gender is ' \
|
|
|
|
'unknown.'))
|
|
|
|
menu.add_option(category, 'colorunknown', color_unknown)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
color_family = ColourOption(_('Families'), '#ffffe0')
|
|
|
|
color_family.set_help(_('The colour to use to display families.'))
|
|
|
|
menu.add_option(category, 'colorfamilies', color_family)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-01-28 18:55:22 +05:30
|
|
|
self.limit_parents = BooleanOption(_('Limit the number of parents'),
|
|
|
|
False)
|
|
|
|
self.limit_parents.set_help(
|
|
|
|
_('The maximum number of ancestors to include.'))
|
2008-04-28 09:29:55 +05:30
|
|
|
menu.add_option(category, 'limitparents', self.limit_parents)
|
2008-01-28 18:55:22 +05:30
|
|
|
self.limit_parents.connect('value-changed', self.limit_changed)
|
|
|
|
|
|
|
|
self.max_parents = NumberOption('', 50, 10, 9999)
|
|
|
|
self.max_parents.set_help(
|
|
|
|
_('The maximum number of ancestors to include.'))
|
2008-04-28 09:29:55 +05:30
|
|
|
menu.add_option(category, 'maxparents', self.max_parents)
|
2008-01-28 18:55:22 +05:30
|
|
|
|
|
|
|
self.limit_children = BooleanOption(_('Limit the number of children'),
|
|
|
|
False)
|
|
|
|
self.limit_children.set_help(
|
|
|
|
_('The maximum number of children to include.'))
|
2008-04-28 09:29:55 +05:30
|
|
|
menu.add_option(category, 'limitchildren', self.limit_children)
|
2008-01-28 18:55:22 +05:30
|
|
|
self.limit_children.connect('value-changed', self.limit_changed)
|
|
|
|
|
|
|
|
self.max_children = NumberOption('', 50, 10, 9999)
|
|
|
|
self.max_children.set_help(
|
|
|
|
_('The maximum number of children to include.'))
|
2008-04-28 09:29:55 +05:30
|
|
|
menu.add_option(category, 'maxchildren', self.max_children)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-12 13:09:39 +05:30
|
|
|
color = EnumeratedListOption(_("Graph coloring"), "filled")
|
|
|
|
for i in range( 0, len(_COLORS) ):
|
|
|
|
color.add_item(_COLORS[i]["value"], _COLORS[i]["name"])
|
|
|
|
color.set_help(_("Males will be shown with blue, females "
|
|
|
|
"with red, unless otherwise set above for filled."
|
|
|
|
" If the sex of an individual "
|
|
|
|
"is unknown it will be shown with gray."))
|
2008-04-28 09:29:55 +05:30
|
|
|
menu.add_option(category, "color", color)
|
2008-04-12 13:09:39 +05:30
|
|
|
|
2007-12-28 15:38:19 +05:30
|
|
|
# --------------------
|
|
|
|
category = _('Images')
|
|
|
|
# --------------------
|
|
|
|
|
2008-01-28 18:55:22 +05:30
|
|
|
self.include_images = BooleanOption(
|
|
|
|
_('Include thumbnail images of people'), True)
|
|
|
|
self.include_images.set_help(
|
|
|
|
_('The maximum number of children to include.'))
|
2008-04-28 09:29:55 +05:30
|
|
|
menu.add_option(category, 'incimages', self.include_images)
|
2008-01-28 18:55:22 +05:30
|
|
|
self.include_images.connect('value-changed', self.images_changed)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-01-28 18:55:22 +05:30
|
|
|
self.image_location = EnumeratedListOption(_('Thumbnail location'), 0)
|
|
|
|
self.image_location.add_item(0, _('Above the name'))
|
|
|
|
self.image_location.add_item(1, _('Beside the name'))
|
|
|
|
self.image_location.set_help(
|
|
|
|
_('Where the thumbnail image should appear relative to the name'))
|
2008-04-28 09:29:55 +05:30
|
|
|
menu.add_option(category, 'imageonside', self.image_location)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# ---------------------
|
|
|
|
category = _('Options')
|
|
|
|
# ---------------------
|
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
use_subgraphs = BooleanOption(_('Use subgraphs'), False)
|
|
|
|
use_subgraphs.set_help(_("Subgraphs can help GraphViz position "
|
2007-12-31 11:13:14 +05:30
|
|
|
"certain linked nodes closer together, "
|
|
|
|
"but with non-trivial graphs will result "
|
|
|
|
"in longer lines and larger graphs."))
|
2008-04-28 09:29:55 +05:30
|
|
|
menu.add_option(category, "usesubgraphs", use_subgraphs)
|
|
|
|
|
|
|
|
include_dates = BooleanOption(_('Include dates'), True)
|
|
|
|
include_dates.set_help(_('Whether to include dates for people and ' \
|
|
|
|
'families.'))
|
|
|
|
menu.add_option(category, 'incdates', include_dates)
|
|
|
|
|
|
|
|
include_places = BooleanOption(_('Include places'), True)
|
|
|
|
include_places.set_help(_('Whether to include placenames for people ' \
|
|
|
|
'and families.'))
|
|
|
|
menu.add_option(category, 'incplaces', include_places)
|
|
|
|
|
|
|
|
include_num_children = BooleanOption(
|
|
|
|
_('Include the number of children'), True)
|
|
|
|
include_num_children.set_help(_('Whether to include the number of ' \
|
|
|
|
'children for families with more ' \
|
|
|
|
'than 1 child.'))
|
|
|
|
menu.add_option(category, 'incchildcnt', include_num_children)
|
|
|
|
|
|
|
|
include_researcher = BooleanOption(
|
|
|
|
_('Include researcher and date'), True)
|
|
|
|
include_researcher.set_help(_('Whether to include at the bottom the ' \
|
|
|
|
'researcher''s name, e-mail, and the ' \
|
|
|
|
'date the graph was generated.'))
|
|
|
|
menu.add_option(category, 'incresearcher', include_researcher)
|
|
|
|
|
|
|
|
include_private = BooleanOption(_('Include private records'), False)
|
|
|
|
include_private.set_help(_('Whether to include names, dates, and ' \
|
|
|
|
'families that are marked as private.'))
|
|
|
|
menu.add_option(category, 'incprivate', include_private)
|
2008-01-28 18:55:22 +05:30
|
|
|
|
|
|
|
self.limit_changed()
|
|
|
|
self.images_changed()
|
2008-01-12 08:56:44 +05:30
|
|
|
|
2008-01-28 18:55:22 +05:30
|
|
|
def limit_changed(self):
|
|
|
|
"""
|
|
|
|
Handle the change of limiting parents and children.
|
|
|
|
"""
|
|
|
|
self.max_parents.set_available(self.limit_parents.get_value())
|
|
|
|
self.max_children.set_available(self.limit_children.get_value())
|
2008-01-12 08:56:44 +05:30
|
|
|
|
2008-01-28 18:55:22 +05:30
|
|
|
def images_changed(self):
|
|
|
|
"""
|
|
|
|
Handle the change of including images.
|
|
|
|
"""
|
|
|
|
self.image_location.set_available(self.include_images.get_value())
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# FamilyLinesReport -- created once the user presses 'OK'
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class FamilyLinesReport(Report):
|
2008-02-20 10:22:10 +05:30
|
|
|
def __init__(self, database, options):
|
2007-12-28 15:38:19 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create FamilyLinesReport object that eventually produces the report.
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
The arguments are:
|
|
|
|
|
|
|
|
database - the GRAMPS database instance
|
|
|
|
person - currently selected person
|
|
|
|
options - instance of the FamilyLinesOptions class for this report
|
|
|
|
"""
|
2008-02-20 10:22:10 +05:30
|
|
|
Report.__init__(self, database, options)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-12 13:09:39 +05:30
|
|
|
colored = {
|
|
|
|
'male': 'dodgerblue4',
|
|
|
|
'female': 'deeppink',
|
|
|
|
'unknown': 'black',
|
|
|
|
'family': 'darkgreen'
|
|
|
|
}
|
|
|
|
filled = {
|
|
|
|
'male': 'lightblue',
|
|
|
|
'female': 'lightpink',
|
|
|
|
'unknown': 'lightgray',
|
|
|
|
'family': 'lightyellow'
|
|
|
|
}
|
|
|
|
|
2007-12-28 15:38:19 +05:30
|
|
|
# initialize several convenient variables
|
2008-04-28 09:29:55 +05:30
|
|
|
self._db = database
|
|
|
|
self._people = set() # handle of people we need in the report
|
|
|
|
self._families = set() # handle of families we need in the report
|
|
|
|
self._deleted_people = 0
|
|
|
|
self._deleted_families = 0
|
|
|
|
|
|
|
|
menu = options.menu
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('followpar')
|
|
|
|
self._followpar = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('followchild')
|
|
|
|
self._followchild = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('removeextra')
|
|
|
|
self._removeextra = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('gidlist')
|
|
|
|
self._gidlist = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('colormales')
|
|
|
|
self._colormales = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('colorfemales')
|
|
|
|
self._colorfemales = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('colorunknown')
|
|
|
|
self._colorunknown = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('colorfamilies')
|
|
|
|
self._colorfamilies = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('limitparents')
|
|
|
|
self._limitparents = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('maxparents')
|
|
|
|
self._maxparents = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('limitchildren')
|
|
|
|
self._limitchildren = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('maxchildren')
|
|
|
|
self._maxchildren = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('incimages')
|
|
|
|
self._incimages = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('imageonside')
|
|
|
|
self._imageonside = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('usesubgraphs')
|
|
|
|
self._usesubgraphs = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('incdates')
|
|
|
|
self._incdates = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('incplaces')
|
|
|
|
self._incplaces = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('incchildcnt')
|
|
|
|
self._incchildcount = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('incresearcher')
|
|
|
|
self._incresearcher = _opt.get_value()
|
|
|
|
|
|
|
|
_opt = menu.get_option_by_name('incprivate')
|
|
|
|
self._incprivate = _opt.get_value()
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# the gidlist is annoying for us to use since we always have to convert
|
|
|
|
# the GIDs to either Person or to handles, so we may as well convert the
|
|
|
|
# entire list right now and not have to deal with it ever again
|
2008-04-28 09:29:55 +05:30
|
|
|
self._interest_set = set()
|
|
|
|
for gid in self._gidlist.split():
|
|
|
|
person = self._db.get_person_from_gramps_id(gid)
|
|
|
|
self._interest_set.add(person.get_handle())
|
|
|
|
|
|
|
|
# convert the 'surnamecolors' string to a dictionary of names and colors
|
|
|
|
self._surnamecolors = {}
|
|
|
|
_opt = menu.get_option_by_name('surnamecolors')
|
|
|
|
tmp = _opt.get_value().split()
|
2007-12-28 15:38:19 +05:30
|
|
|
while len(tmp) > 1:
|
|
|
|
surname = tmp.pop(0).encode('iso-8859-1','xmlcharrefreplace')
|
|
|
|
colour = tmp.pop(0)
|
2008-04-28 09:29:55 +05:30
|
|
|
self._surnamecolors[surname] = colour
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
self._colorize = menu.get_option_by_name('color').get_value()
|
|
|
|
if self._colorize == 'colored':
|
|
|
|
self._colors = colored
|
|
|
|
elif self._colorize == 'filled':
|
|
|
|
self._colors = filled
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
def begin_report(self):
|
2008-04-28 09:29:55 +05:30
|
|
|
"""
|
|
|
|
Inherited method; called by report() in _ReportDialog.py
|
|
|
|
|
|
|
|
This is where we'll do all of the work of figuring out who
|
|
|
|
from the database is going to be output into the report
|
|
|
|
"""
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
self.progress = Utils.ProgressMeter(_('Generating Family Lines'),
|
|
|
|
_('Starting'))
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# starting with the people of interest, we then add parents:
|
2008-04-28 09:29:55 +05:30
|
|
|
self._people.clear()
|
|
|
|
self._families.clear()
|
|
|
|
self.progress.set_pass(_('Finding ancestors and children'),
|
|
|
|
self._db.get_number_of_people())
|
|
|
|
if self._followpar:
|
2007-12-28 15:38:19 +05:30
|
|
|
self.findParents()
|
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._removeextra:
|
2007-12-28 15:38:19 +05:30
|
|
|
self.removeUninterestingParents()
|
|
|
|
|
|
|
|
# ...and/or with the people of interest we add their children:
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._followchild:
|
2007-12-28 15:38:19 +05:30
|
|
|
self.findChildren()
|
|
|
|
# once we get here we have a full list of people
|
|
|
|
# and families that we need to generate a report
|
|
|
|
|
|
|
|
|
|
|
|
def write_report(self):
|
2008-04-28 09:29:55 +05:30
|
|
|
"""
|
|
|
|
Inherited method; called by report() in _ReportDialog.py
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
Since we know the exact number of people and families,
|
|
|
|
we can then restart the progress bar with the exact number
|
|
|
|
"""
|
|
|
|
|
2007-12-28 15:38:19 +05:30
|
|
|
self.progress.set_pass(_('Writing family lines'),
|
2008-04-28 09:29:55 +05:30
|
|
|
len(self._people ) + # every person needs to be written
|
|
|
|
len(self._families ) + # every family needs to be written
|
|
|
|
len(self._families )) # every family needs people assigned to it
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# now that begin_report() has done the work, output what we've
|
|
|
|
# obtained into whatever file or format the user expects to use
|
2007-12-31 11:13:14 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
self.doc.add_comment('# Number of people in database: %d'
|
|
|
|
% self._db.get_number_of_people())
|
|
|
|
self.doc.add_comment('# Number of people of interest: %d'
|
|
|
|
% len(self._people))
|
|
|
|
self.doc.add_comment('# Number of families in database: %d'
|
|
|
|
% self._db.get_number_of_families())
|
|
|
|
self.doc.add_comment('# Number of families of interest: %d'
|
|
|
|
% len(self._families))
|
|
|
|
if self._removeextra:
|
|
|
|
self.doc.add_comment('# Additional people removed: %d'
|
|
|
|
% self._deleted_people)
|
|
|
|
self.doc.add_comment('# Additional families removed: %d'
|
|
|
|
% self._deleted_families)
|
2008-01-02 14:13:19 +05:30
|
|
|
self.doc.add_comment('# Initial list of people of interest:')
|
2008-04-28 09:29:55 +05:30
|
|
|
for handle in self._interest_set:
|
|
|
|
person = self._db.get_person_from_handle(handle)
|
2007-12-31 11:13:14 +05:30
|
|
|
gid = person.get_gramps_id()
|
|
|
|
name = person.get_primary_name().get_regular_name()
|
2008-01-02 14:13:19 +05:30
|
|
|
self.doc.add_comment('# -> %s, %s' % (gid, name))
|
2007-12-31 11:13:14 +05:30
|
|
|
|
2007-12-28 15:38:19 +05:30
|
|
|
self.writePeople()
|
|
|
|
self.writeFamilies()
|
|
|
|
self.progress.close()
|
|
|
|
|
|
|
|
|
|
|
|
def findParents(self):
|
|
|
|
# we need to start with all of our "people of interest"
|
2008-04-28 09:29:55 +05:30
|
|
|
ancestorsNotYetProcessed = set(self._interest_set)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# now we find all the immediate ancestors of our people of interest
|
|
|
|
|
|
|
|
while len(ancestorsNotYetProcessed) > 0:
|
|
|
|
handle = ancestorsNotYetProcessed.pop()
|
|
|
|
self.progress.step()
|
|
|
|
|
|
|
|
# One of 2 things can happen here:
|
2008-04-28 09:29:55 +05:30
|
|
|
# 1) we've already know about this person and he/she is already
|
|
|
|
# in our list
|
2007-12-28 15:38:19 +05:30
|
|
|
# 2) this is someone new, and we need to remember him/her
|
|
|
|
#
|
2008-04-28 09:29:55 +05:30
|
|
|
# In the first case, there isn't anything else to do, so we simply
|
|
|
|
# go back to the top and pop the next person off the list.
|
2007-12-28 15:38:19 +05:30
|
|
|
#
|
2008-04-28 09:29:55 +05:30
|
|
|
# In the second case, we need to add this person to our list, and
|
|
|
|
# then go through all of the parents this person has to find more
|
|
|
|
# people of interest.
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
if handle not in self._people:
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
person = self._db.get_person_from_handle(handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# if this is a private record, and we're not
|
|
|
|
# including private records, then go back to the
|
|
|
|
# top of the while loop to get the next person
|
2008-04-28 09:29:55 +05:30
|
|
|
if person.private and not self._incprivate:
|
2007-12-28 15:38:19 +05:30
|
|
|
continue
|
|
|
|
|
|
|
|
# remember this person!
|
2008-04-28 09:29:55 +05:30
|
|
|
self._people.add(handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# see if a family exists between this person and someone else
|
|
|
|
# we have on our list of people we're going to output -- if
|
|
|
|
# there is a family, then remember it for when it comes time
|
|
|
|
# to link spouses together
|
2008-04-28 09:29:55 +05:30
|
|
|
for family_handle in person.get_family_handle_list():
|
|
|
|
family = self._db.get_family_from_handle(family_handle)
|
|
|
|
spouse_handle = ReportUtils.find_spouse(person, family)
|
|
|
|
if spouse_handle:
|
|
|
|
if spouse_handle in self._people or \
|
|
|
|
spouse_handle in ancestorsNotYetProcessed:
|
|
|
|
self._families.add(family_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# if we have a limit on the number of people, and we've
|
|
|
|
# reached that limit, then don't attempt to find any
|
|
|
|
# more ancestors
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._limitparents and \
|
|
|
|
( self._maxparents < \
|
|
|
|
( len(ancestorsNotYetProcessed) + len(self._people) ) ):
|
2007-12-28 15:38:19 +05:30
|
|
|
# get back to the top of the while loop so we can finish
|
2008-04-28 09:29:55 +05:30
|
|
|
# processing the people queued up in the "not yet
|
|
|
|
# processed" list
|
2007-12-28 15:38:19 +05:30
|
|
|
continue
|
|
|
|
|
|
|
|
# queue the parents of the person we're processing
|
2008-04-28 09:29:55 +05:30
|
|
|
for family_handle in person.get_parent_family_handle_list():
|
|
|
|
family = self._db.get_family_from_handle(family_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
if (family.private and self._incprivate) or \
|
|
|
|
not family.private:
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
father = self._db.get_person_from_handle(
|
|
|
|
family.get_father_handle())
|
|
|
|
mother = self._db.get_person_from_handle(
|
|
|
|
family.get_mother_handle())
|
2007-12-28 15:38:19 +05:30
|
|
|
if father:
|
2008-04-28 09:29:55 +05:30
|
|
|
if (father.private and self._incprivate) or \
|
|
|
|
not father.private:
|
|
|
|
ancestorsNotYetProcessed.add(
|
|
|
|
family.get_father_handle())
|
|
|
|
self._families.add(family_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
if mother:
|
2008-04-28 09:29:55 +05:30
|
|
|
if (mother.private and self._incprivate) or \
|
|
|
|
not mother.private:
|
|
|
|
ancestorsNotYetProcessed.add(
|
|
|
|
family.get_mother_handle())
|
|
|
|
self._families.add(family_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
def removeUninterestingParents(self):
|
|
|
|
# start with all the people we've already identified
|
2008-04-28 09:29:55 +05:30
|
|
|
unprocessed_parents = set(self._people)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
while len(unprocessed_parents) > 0:
|
|
|
|
handle = unprocessed_parents.pop()
|
2007-12-28 15:38:19 +05:30
|
|
|
self.progress.step()
|
2008-04-28 09:29:55 +05:30
|
|
|
person = self._db.get_person_from_handle(handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# There are a few things we're going to need,
|
|
|
|
# so look it all up right now; such as:
|
|
|
|
# - who is the child?
|
|
|
|
# - how many children?
|
|
|
|
# - parents?
|
|
|
|
# - spouse?
|
|
|
|
# - is a person of interest?
|
|
|
|
# - spouse of a person of interest?
|
|
|
|
# - same surname as a person of interest?
|
|
|
|
# - spouse has the same surname as a person of interest?
|
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
child_handle = None
|
|
|
|
child_count = 0
|
|
|
|
spouse_handle = None
|
|
|
|
spouse_count = 0
|
|
|
|
father_handle = None
|
|
|
|
mother_handle = None
|
|
|
|
spouse_father_handle = None
|
|
|
|
spouse_mother_handle = None
|
|
|
|
spouse_surname = ""
|
|
|
|
surname = person.get_primary_name().get_surname()
|
|
|
|
surname = surname.encode('iso-8859-1','xmlcharrefreplace')
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# first we get the person's father and mother
|
2008-04-28 09:29:55 +05:30
|
|
|
for family_handle in person.get_parent_family_handle_list():
|
|
|
|
family = self._db.get_family_from_handle(family_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
handle = family.get_father_handle()
|
2008-04-28 09:29:55 +05:30
|
|
|
if handle in self._people:
|
|
|
|
father_handle = handle
|
2007-12-28 15:38:19 +05:30
|
|
|
handle = family.get_mother_handle()
|
2008-04-28 09:29:55 +05:30
|
|
|
if handle in self._people:
|
|
|
|
mother_handle = handle
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# now see how many spouses this person has
|
2008-04-28 09:29:55 +05:30
|
|
|
for family_handle in person.get_family_handle_list():
|
|
|
|
family = self._db.get_family_from_handle(family_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
handle = ReportUtils.find_spouse(person, family)
|
2008-04-28 09:29:55 +05:30
|
|
|
if handle in self._people:
|
|
|
|
spouse_count += 1
|
|
|
|
spouse = self._db.get_person_from_handle(handle)
|
|
|
|
spouse_handle = handle
|
|
|
|
spouse_surname = spouse.get_primary_name().get_surname()
|
|
|
|
spouse_surname = spouse_surname.encode('iso-8859-1',
|
|
|
|
'xmlcharrefreplace')
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# see if the spouse has parents
|
2008-04-28 09:29:55 +05:30
|
|
|
if spouse_father_handle == None and \
|
|
|
|
spouse_mother_handle == None:
|
|
|
|
for family_handle in \
|
|
|
|
spouse.get_parent_family_handle_list():
|
|
|
|
family = self._db.get_family_from_handle(
|
|
|
|
family_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
handle = family.get_father_handle()
|
2008-04-28 09:29:55 +05:30
|
|
|
if handle in self._people:
|
|
|
|
spouse_father_handle = handle
|
2007-12-28 15:38:19 +05:30
|
|
|
handle = family.get_mother_handle()
|
2008-04-28 09:29:55 +05:30
|
|
|
if handle in self._people:
|
|
|
|
spouse_mother_handle = handle
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# get the number of children that we think might be interesting
|
2008-04-28 09:29:55 +05:30
|
|
|
for family_handle in person.get_family_handle_list():
|
|
|
|
family = self._db.get_family_from_handle(family_handle)
|
|
|
|
for child_ref in family.get_child_ref_list():
|
|
|
|
if child_ref.ref in self._people:
|
|
|
|
child_count += 1
|
|
|
|
child_handle = child_ref.ref
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# we now have everything we need -- start looking for reasons
|
|
|
|
# why this is a person we need to keep in our list, and loop
|
|
|
|
# back to the top as soon as a reason is discovered
|
|
|
|
|
|
|
|
# if this person has many children of interest, then we
|
|
|
|
# automatically keep this person
|
2008-04-28 09:29:55 +05:30
|
|
|
if child_count > 1:
|
2007-12-28 15:38:19 +05:30
|
|
|
continue
|
|
|
|
|
|
|
|
# if this person has many spouses of interest, then we
|
|
|
|
# automatically keep this person
|
2008-04-28 09:29:55 +05:30
|
|
|
if spouse_count > 1:
|
2007-12-28 15:38:19 +05:30
|
|
|
continue
|
|
|
|
|
|
|
|
# if this person has parents, then we automatically keep
|
|
|
|
# this person
|
2008-04-28 09:29:55 +05:30
|
|
|
if father_handle != None or mother_handle != None:
|
2007-12-28 15:38:19 +05:30
|
|
|
continue
|
|
|
|
|
|
|
|
# if the spouse has parents, then we automatically keep
|
|
|
|
# this person
|
2008-04-28 09:29:55 +05:30
|
|
|
if spouse_father_handle != None or spouse_mother_handle != None:
|
|
|
|
continue
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# if this is a person of interest, then we automatically keep
|
2008-04-28 09:29:55 +05:30
|
|
|
if person.get_handle() in self._interest_set:
|
|
|
|
continue
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# if the spouse is a person of interest, then we keep
|
2008-04-28 09:29:55 +05:30
|
|
|
if spouse_handle in self._interest_set:
|
2007-12-28 15:38:19 +05:30
|
|
|
continue
|
|
|
|
|
|
|
|
# if the surname (or the spouse's surname) matches a person
|
|
|
|
# of interest, then we automatically keep this person
|
|
|
|
bKeepThisPerson = False
|
2008-04-28 09:29:55 +05:30
|
|
|
for personOfInterestHandle in self._interest_set:
|
|
|
|
personOfInterest = self._db.get_person_from_handle(personOfInterestHandle)
|
2007-12-28 15:38:19 +05:30
|
|
|
surnameOfInterest = personOfInterest.get_primary_name().get_surname().encode('iso-8859-1','xmlcharrefreplace')
|
2008-04-28 09:29:55 +05:30
|
|
|
if surnameOfInterest == surname or surnameOfInterest == spouse_surname:
|
2007-12-28 15:38:19 +05:30
|
|
|
bKeepThisPerson = True
|
|
|
|
break
|
|
|
|
|
|
|
|
if bKeepThisPerson:
|
|
|
|
continue
|
|
|
|
|
|
|
|
# if we have a special colour to use for this person,
|
|
|
|
# then we automatically keep this person
|
2008-04-28 09:29:55 +05:30
|
|
|
if surname in self._surnamecolors:
|
2007-12-28 15:38:19 +05:30
|
|
|
continue
|
|
|
|
|
|
|
|
# if we have a special colour to use for the spouse,
|
|
|
|
# then we automatically keep this person
|
2008-04-28 09:29:55 +05:30
|
|
|
if spouse_surname in self._surnamecolors:
|
2007-12-28 15:38:19 +05:30
|
|
|
continue
|
|
|
|
|
|
|
|
# took us a while, but if we get here, then we can remove this person
|
2008-04-28 09:29:55 +05:30
|
|
|
self._deleted_people += 1
|
|
|
|
self._people.remove(person.get_handle())
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# we can also remove any families to which this person belonged
|
2008-04-28 09:29:55 +05:30
|
|
|
for family_handle in person.get_family_handle_list():
|
|
|
|
if family_handle in self._families:
|
|
|
|
self._deleted_families += 1
|
|
|
|
self._families.remove(family_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# if we have a spouse, then ensure we queue up the spouse
|
2008-04-28 09:29:55 +05:30
|
|
|
if spouse_handle:
|
|
|
|
if spouse_handle not in unprocessed_parents:
|
|
|
|
unprocessed_parents.add(spouse_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# if we have a child, then ensure we queue up the child
|
2008-04-28 09:29:55 +05:30
|
|
|
if child_handle:
|
|
|
|
if child_handle not in unprocessed_parents:
|
|
|
|
unprocessed_parents.add(child_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
|
|
|
|
def findChildren(self):
|
|
|
|
# we need to start with all of our "people of interest"
|
2008-04-28 09:29:55 +05:30
|
|
|
childrenNotYetProcessed = set(self._interest_set)
|
2007-12-28 15:38:19 +05:30
|
|
|
childrenToInclude = set()
|
|
|
|
|
|
|
|
# now we find all the children of our people of interest
|
|
|
|
|
|
|
|
while len(childrenNotYetProcessed) > 0:
|
|
|
|
handle = childrenNotYetProcessed.pop()
|
|
|
|
self.progress.step()
|
|
|
|
|
|
|
|
if handle not in childrenToInclude:
|
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
person = self._db.get_person_from_handle(handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# if this is a private record, and we're not
|
|
|
|
# including private records, then go back to the
|
|
|
|
# top of the while loop to get the next person
|
2008-04-28 09:29:55 +05:30
|
|
|
if person.private and not self._incprivate:
|
2007-12-28 15:38:19 +05:30
|
|
|
continue
|
|
|
|
|
|
|
|
# remember this person!
|
|
|
|
childrenToInclude.add(handle)
|
|
|
|
|
|
|
|
# if we have a limit on the number of people, and we've
|
|
|
|
# reached that limit, then don't attempt to find any
|
|
|
|
# more children
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._limitchildren and (self._maxchildren < ( len(childrenNotYetProcessed) + len(childrenToInclude))):
|
2007-12-28 15:38:19 +05:30
|
|
|
# get back to the top of the while loop so we can finish
|
|
|
|
# processing the people queued up in the "not yet processed" list
|
|
|
|
continue
|
|
|
|
|
|
|
|
# iterate through this person's families
|
2008-04-28 09:29:55 +05:30
|
|
|
for family_handle in person.get_family_handle_list():
|
|
|
|
family = self._db.get_family_from_handle(family_handle)
|
|
|
|
if (family.private and self._incprivate) or not family.private:
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# queue up any children from this person's family
|
|
|
|
for childRef in family.get_child_ref_list():
|
2008-04-28 09:29:55 +05:30
|
|
|
child = self._db.get_person_from_handle(childRef.ref)
|
|
|
|
if (child.private and self._incprivate) or not child.private:
|
2007-12-28 15:38:19 +05:30
|
|
|
childrenNotYetProcessed.add(child.get_handle())
|
2008-04-28 09:29:55 +05:30
|
|
|
self._families.add(family_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# include the spouse from this person's family
|
2008-04-28 09:29:55 +05:30
|
|
|
spouse_handle = ReportUtils.find_spouse(person, family)
|
|
|
|
if spouse_handle:
|
|
|
|
spouse = self._db.get_person_from_handle(spouse_handle)
|
|
|
|
if (spouse.private and self._incprivate) or not spouse.private:
|
|
|
|
childrenToInclude.add(spouse_handle)
|
|
|
|
self._families.add(family_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# we now merge our temp set "childrenToInclude" into our master set
|
2008-04-28 09:29:55 +05:30
|
|
|
self._people.update(childrenToInclude)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
|
|
|
|
def writePeople(self):
|
2007-12-31 11:13:14 +05:30
|
|
|
|
2008-01-02 14:13:19 +05:30
|
|
|
self.doc.add_comment('')
|
2007-12-31 11:13:14 +05:30
|
|
|
|
2007-12-28 15:38:19 +05:30
|
|
|
# if we're going to attempt to include images, then use the HTML style of .dot file
|
|
|
|
bUseHtmlOutput = False
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._incimages:
|
2007-12-28 15:38:19 +05:30
|
|
|
bUseHtmlOutput = True
|
|
|
|
|
|
|
|
# loop through all the people we need to output
|
2008-04-28 09:29:55 +05:30
|
|
|
for handle in self._people:
|
2007-12-28 15:38:19 +05:30
|
|
|
self.progress.step()
|
2008-04-28 09:29:55 +05:30
|
|
|
person = self._db.get_person_from_handle(handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
name = person.get_primary_name().get_regular_name()
|
|
|
|
|
|
|
|
# figure out what colour to use
|
2008-04-28 09:29:55 +05:30
|
|
|
colour = self._colorunknown
|
2007-12-28 15:38:19 +05:30
|
|
|
if person.get_gender() == gen.lib.Person.MALE:
|
2008-04-28 09:29:55 +05:30
|
|
|
colour = self._colormales
|
2007-12-28 15:38:19 +05:30
|
|
|
if person.get_gender() == gen.lib.Person.FEMALE:
|
2008-04-28 09:29:55 +05:30
|
|
|
colour = self._colorfemales
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# see if we have surname colours that match this person
|
|
|
|
surname = person.get_primary_name().get_surname().encode('iso-8859-1','xmlcharrefreplace')
|
2008-04-28 09:29:55 +05:30
|
|
|
if surname in self._surnamecolors:
|
|
|
|
colour = self._surnamecolors[surname]
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-01-24 04:25:51 +05:30
|
|
|
# see if we have a birth/death or fallback dates we can use
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._incdates or self._incplaces:
|
|
|
|
bth_event = ReportUtils.get_birth_or_fallback(self._db, person)
|
|
|
|
dth_event = ReportUtils.get_death_or_fallback(self._db, person)
|
2008-01-24 04:25:51 +05:30
|
|
|
else:
|
|
|
|
bth_event = None
|
|
|
|
dth_event = None
|
|
|
|
|
|
|
|
# output the birth or fallback event
|
2007-12-28 15:38:19 +05:30
|
|
|
birthStr = None
|
2008-04-28 09:29:55 +05:30
|
|
|
if bth_event and self._incdates:
|
|
|
|
if (bth_event.private and self._incprivate) or \
|
2008-01-24 04:25:51 +05:30
|
|
|
not bth_event.private:
|
|
|
|
date = bth_event.get_date_object()
|
2008-02-27 14:07:01 +05:30
|
|
|
birthStr = _dd.display(date)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-01-24 04:25:51 +05:30
|
|
|
# get birth place (one of: city, state, or country) we can use
|
2007-12-28 15:38:19 +05:30
|
|
|
birthplace = None
|
2008-04-28 09:29:55 +05:30
|
|
|
if bth_event and self._incplaces:
|
|
|
|
if (bth_event.private and self._incprivate) or \
|
2008-01-24 04:25:51 +05:30
|
|
|
not bth_event.private:
|
2008-04-28 09:29:55 +05:30
|
|
|
place = self._db.get_place_from_handle(bth_event.get_place_handle())
|
2007-12-28 15:38:19 +05:30
|
|
|
if place:
|
|
|
|
location = place.get_main_location()
|
|
|
|
if location.get_city:
|
|
|
|
birthplace = location.get_city()
|
|
|
|
elif location.get_state:
|
|
|
|
birthplace = location.get_state()
|
|
|
|
elif location.get_country:
|
|
|
|
birthplace = location.get_country()
|
|
|
|
|
|
|
|
# see if we have a deceased date we can use
|
|
|
|
deathStr = None
|
2008-04-28 09:29:55 +05:30
|
|
|
if dth_event and self._incdates:
|
|
|
|
if (dth_event.private and self._incprivate) or \
|
2008-01-24 04:25:51 +05:30
|
|
|
not dth_event.private:
|
|
|
|
date = dth_event.get_date_object()
|
2008-02-27 14:07:01 +05:30
|
|
|
deathStr = _dd.display(date)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-01-24 04:25:51 +05:30
|
|
|
# get death place (one of: city, state, or country) we can use
|
2007-12-28 15:38:19 +05:30
|
|
|
deathplace = None
|
2008-04-28 09:29:55 +05:30
|
|
|
if dth_event and self._incplaces:
|
|
|
|
if (dth_event.private and self._incprivate) or \
|
2008-01-24 04:25:51 +05:30
|
|
|
not dth_event.private:
|
2008-04-28 09:29:55 +05:30
|
|
|
place = self._db.get_place_from_handle(dth_event.get_place_handle())
|
2007-12-28 15:38:19 +05:30
|
|
|
if place:
|
|
|
|
location = place.get_main_location()
|
|
|
|
if location.get_city:
|
|
|
|
deathplace = location.get_city()
|
|
|
|
elif location.get_state:
|
|
|
|
deathplace = location.get_state()
|
|
|
|
elif location.get_country:
|
|
|
|
deathplace = location.get_country()
|
|
|
|
|
|
|
|
# see if we have an image to use for this person
|
|
|
|
imagePath = None
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._incimages:
|
2007-12-28 15:38:19 +05:30
|
|
|
mediaList = person.get_media_list()
|
|
|
|
if len(mediaList) > 0:
|
|
|
|
mediaHandle = mediaList[0].get_reference_handle()
|
2008-04-28 09:29:55 +05:30
|
|
|
media = self._db.get_object_from_handle(mediaHandle)
|
2007-12-28 15:38:19 +05:30
|
|
|
mediaMimeType = media.get_mime_type()
|
|
|
|
if mediaMimeType[0:5] == "image":
|
2008-02-18 19:36:41 +05:30
|
|
|
imagePath = ThumbNails.get_thumbnail_path(
|
2008-04-28 09:29:55 +05:30
|
|
|
Utils.media_path_full(self._db,
|
2008-02-18 19:36:41 +05:30
|
|
|
media.get_path())
|
|
|
|
)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# put the label together and ouput this person
|
|
|
|
label = u""
|
|
|
|
lineDelimiter = '\\n'
|
|
|
|
if bUseHtmlOutput:
|
|
|
|
lineDelimiter = '<BR/>'
|
|
|
|
|
|
|
|
# if we have an image, then start an HTML table; remember to close the table afterwards!
|
|
|
|
if imagePath:
|
|
|
|
label = u'<TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0" CELLBORDER="0"><TR><TD><IMG SRC="%s"/></TD>' % imagePath
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._imageonside == 0:
|
2007-12-28 15:38:19 +05:30
|
|
|
label += u'</TR><TR>'
|
|
|
|
label += '<TD>'
|
|
|
|
|
|
|
|
# at the very least, the label must have the person's name
|
|
|
|
label += name
|
|
|
|
|
|
|
|
if birthStr or deathStr:
|
|
|
|
label += ' %s(' % lineDelimiter
|
|
|
|
if birthStr:
|
|
|
|
label += '%s' % birthStr
|
|
|
|
label += ' - '
|
|
|
|
if deathStr:
|
|
|
|
label += '%s' % deathStr
|
|
|
|
label += ')'
|
|
|
|
if birthplace or deathplace:
|
|
|
|
if birthplace == deathplace:
|
|
|
|
deathplace = None # no need to print the same name twice
|
|
|
|
label += ' %s' % lineDelimiter
|
|
|
|
if birthplace:
|
|
|
|
label += '%s' % birthplace
|
|
|
|
if birthplace and deathplace:
|
|
|
|
label += ' / '
|
|
|
|
if deathplace:
|
|
|
|
label += '%s' % deathplace
|
|
|
|
|
|
|
|
# see if we have a table that needs to be terminated
|
|
|
|
if imagePath:
|
|
|
|
label += '</TD></TR></TABLE>'
|
|
|
|
|
2008-04-12 13:09:39 +05:30
|
|
|
gender = person.get_gender()
|
|
|
|
shape = "box"
|
|
|
|
style = ""
|
|
|
|
color = ""
|
|
|
|
fill = ""
|
|
|
|
if gender == person.MALE:
|
|
|
|
shape = "box"
|
|
|
|
style = "solid"
|
|
|
|
elif gender == person.FEMALE:
|
|
|
|
shape = "box"
|
|
|
|
style = "rounded"
|
|
|
|
else:
|
|
|
|
shape = "hexagon"
|
2008-05-06 20:18:23 +05:30
|
|
|
style = "solid"
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._colorize == 'colored':
|
2008-04-12 13:09:39 +05:30
|
|
|
if gender == person.MALE:
|
2008-04-28 09:29:55 +05:30
|
|
|
color = self._colors['male']
|
2008-04-12 13:09:39 +05:30
|
|
|
elif gender == person.FEMALE:
|
2008-04-28 09:29:55 +05:30
|
|
|
color = self._colors['female']
|
2008-04-12 13:09:39 +05:30
|
|
|
else:
|
2008-04-28 09:29:55 +05:30
|
|
|
color = self._colors['unknown']
|
|
|
|
elif self._colorize == 'filled':
|
2008-04-12 13:09:39 +05:30
|
|
|
if style != "":
|
|
|
|
style += ",filled"
|
|
|
|
fill = colour
|
|
|
|
else:
|
|
|
|
style = "filled"
|
|
|
|
|
2008-04-23 19:56:54 +05:30
|
|
|
self.doc.add_node(person.get_gramps_id(),
|
2008-04-12 13:09:39 +05:30
|
|
|
label=label,
|
|
|
|
shape=shape,
|
|
|
|
color=color,
|
|
|
|
style=style,
|
|
|
|
fillcolor=fill,
|
|
|
|
htmloutput=bUseHtmlOutput)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
def writeFamilies(self):
|
2007-12-31 11:13:14 +05:30
|
|
|
|
2008-01-02 14:13:19 +05:30
|
|
|
self.doc.add_comment('')
|
2007-12-31 11:13:14 +05:30
|
|
|
|
2007-12-28 15:38:19 +05:30
|
|
|
# loop through all the families we need to output
|
2008-04-28 09:29:55 +05:30
|
|
|
for family_handle in self._families:
|
2007-12-28 15:38:19 +05:30
|
|
|
self.progress.step()
|
2008-04-28 09:29:55 +05:30
|
|
|
family = self._db.get_family_from_handle(family_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
fgid = family.get_gramps_id()
|
|
|
|
|
|
|
|
# figure out a wedding date or placename we can use
|
|
|
|
weddingDate = None
|
|
|
|
weddingPlace = None
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._incdates or self._incplaces:
|
2007-12-28 15:38:19 +05:30
|
|
|
for event_ref in family.get_event_ref_list():
|
2008-04-28 09:29:55 +05:30
|
|
|
event = self._db.get_event_from_handle(event_ref.ref)
|
2007-12-28 15:38:19 +05:30
|
|
|
if event.get_type() == gen.lib.EventType.MARRIAGE:
|
|
|
|
# get the wedding date
|
2008-04-28 09:29:55 +05:30
|
|
|
if (event.private and self._incprivate) or not event.private:
|
|
|
|
if self._incdates:
|
2007-12-28 15:38:19 +05:30
|
|
|
date = event.get_date_object()
|
2008-02-27 14:07:01 +05:30
|
|
|
weddingDate = _dd.display(date)
|
2007-12-28 15:38:19 +05:30
|
|
|
# get the wedding location
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._incplaces:
|
|
|
|
place = self._db.get_place_from_handle(event.get_place_handle())
|
2007-12-28 15:38:19 +05:30
|
|
|
if place:
|
|
|
|
location = place.get_main_location()
|
|
|
|
if location.get_city:
|
|
|
|
weddingPlace = location.get_city()
|
|
|
|
elif location.get_state:
|
|
|
|
weddingPlace = location.get_state()
|
|
|
|
elif location.get_country:
|
|
|
|
weddingPlace = location.get_country()
|
|
|
|
break
|
|
|
|
|
|
|
|
# figure out the number of children (if any)
|
|
|
|
childrenStr = None
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._incchildcount:
|
|
|
|
child_count = len(family.get_child_ref_list())
|
|
|
|
# if child_count == 1:
|
2007-12-28 15:38:19 +05:30
|
|
|
# childrenStr = _('1 child')
|
2008-04-28 09:29:55 +05:30
|
|
|
if child_count > 1:
|
|
|
|
childrenStr = _('%d children') % child_count
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
label = ''
|
|
|
|
if weddingDate:
|
|
|
|
if label != '':
|
|
|
|
label += '\\n'
|
|
|
|
label += '%s' % weddingDate
|
|
|
|
if weddingPlace:
|
|
|
|
if label != '':
|
|
|
|
label += '\\n'
|
|
|
|
label += '%s' % weddingPlace
|
|
|
|
if childrenStr:
|
|
|
|
if label != '':
|
|
|
|
label += '\\n'
|
|
|
|
label += '%s' % childrenStr
|
2008-04-12 13:09:39 +05:30
|
|
|
|
|
|
|
color = ""
|
|
|
|
fill = ""
|
|
|
|
style = "solid"
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._colorize == 'colored':
|
|
|
|
color = self._colors['family']
|
|
|
|
elif self._colorize == 'filled':
|
|
|
|
fill = self._colorfamilies
|
2008-04-12 13:09:39 +05:30
|
|
|
style = "filled"
|
|
|
|
self.doc.add_node(fgid, label, "ellipse", color, style, fill)
|
|
|
|
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# now that we have the families written, go ahead and link the parents and children to the families
|
2008-04-28 09:29:55 +05:30
|
|
|
for family_handle in self._families:
|
2007-12-28 15:38:19 +05:30
|
|
|
self.progress.step()
|
|
|
|
|
|
|
|
# get the parents for this family
|
2008-04-28 09:29:55 +05:30
|
|
|
family = self._db.get_family_from_handle(family_handle)
|
2007-12-28 15:38:19 +05:30
|
|
|
fgid = family.get_gramps_id()
|
2008-04-28 09:29:55 +05:30
|
|
|
father_handle = family.get_father_handle()
|
|
|
|
mother_handle = family.get_mother_handle()
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._usesubgraphs and father_handle and mother_handle:
|
2007-12-30 11:11:16 +05:30
|
|
|
self.doc.start_subgraph(fgid)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-01-02 14:13:19 +05:30
|
|
|
self.doc.add_comment('')
|
2007-12-31 11:13:14 +05:30
|
|
|
|
2007-12-28 15:38:19 +05:30
|
|
|
# see if we have a father to link to this family
|
2008-04-28 09:29:55 +05:30
|
|
|
if father_handle:
|
|
|
|
if father_handle in self._people:
|
|
|
|
father = self._db.get_person_from_handle(father_handle)
|
2007-12-31 11:13:14 +05:30
|
|
|
comment = "father: %s" % father.get_primary_name().get_regular_name()
|
|
|
|
self.doc.add_link(fgid, father.get_gramps_id(), comment=comment)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# see if we have a mother to link to this family
|
2008-04-28 09:29:55 +05:30
|
|
|
if mother_handle:
|
|
|
|
if mother_handle in self._people:
|
|
|
|
mother = self._db.get_person_from_handle(mother_handle)
|
2007-12-31 11:13:14 +05:30
|
|
|
comment = "mother: %s" % mother.get_primary_name().get_regular_name()
|
|
|
|
self.doc.add_link(fgid, mother.get_gramps_id(), comment=comment)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
2008-04-28 09:29:55 +05:30
|
|
|
if self._usesubgraphs and father_handle and mother_handle:
|
2007-12-30 11:11:16 +05:30
|
|
|
self.doc.end_subgraph()
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
# link the children to the family
|
|
|
|
for childRef in family.get_child_ref_list():
|
2008-04-28 09:29:55 +05:30
|
|
|
if childRef.ref in self._people:
|
|
|
|
child = self._db.get_person_from_handle(childRef.ref)
|
2008-01-02 14:13:19 +05:30
|
|
|
comment = "child: %s" % child.get_primary_name().get_regular_name()
|
2007-12-31 11:13:14 +05:30
|
|
|
self.doc.add_link(child.get_gramps_id(), fgid, comment=comment)
|
2007-12-28 15:38:19 +05:30
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# register_report() is defined in _PluginMgr.py and
|
|
|
|
# is used to hook the plugin into GRAMPS so that it
|
|
|
|
# appears in the "Reports" menu options
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2008-05-19 00:54:28 +05:30
|
|
|
pmgr = PluginManager.get_instance()
|
|
|
|
pmgr.register_report(
|
2007-12-28 15:38:19 +05:30
|
|
|
name = 'familylines_graph',
|
2008-03-02 04:17:48 +05:30
|
|
|
translated_name = _("Family Lines Graph"),
|
2007-12-28 15:38:19 +05:30
|
|
|
category = CATEGORY_GRAPHVIZ,
|
2008-03-02 04:17:48 +05:30
|
|
|
report_class = FamilyLinesReport,
|
|
|
|
options_class = FamilyLinesOptions,
|
2007-12-28 15:38:19 +05:30
|
|
|
modes = MODE_GUI,
|
|
|
|
status = _("Stable"),
|
|
|
|
author_name = "Stephane Charette",
|
|
|
|
author_email = "stephanecharette@gmail.com",
|
2008-03-02 04:17:48 +05:30
|
|
|
description = _("Produces family line graphs using GraphViz"),
|
2007-12-28 15:38:19 +05:30
|
|
|
)
|
|
|
|
|