add name-format option to the three GraphViz reports

svn: r22012
This commit is contained in:
Paul Franklin 2013-04-18 17:16:16 +00:00
parent 53b67443f2
commit fa35769714
3 changed files with 57 additions and 22 deletions

View File

@ -6,7 +6,7 @@
# Copyright (C) 2009-2010 Gary Burton
# Contribution 2009 by Bob Ham <rah@bash.sh>
# Copyright (C) 2010 Jakim Friant
# Copyright (C) 2011 Paul Franklin
# Copyright (C) 2011-2013 Paul Franklin
#
# 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
@ -29,16 +29,14 @@
Family Lines, a GraphViz-based plugin for Gramps.
"""
from __future__ import unicode_literals
#------------------------------------------------------------------------
#
# python modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from __future__ import unicode_literals
from functools import partial
import copy
#------------------------------------------------------------------------
#
@ -53,6 +51,8 @@ log = logging.getLogger(".FamilyLines")
# GRAMPS module
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.lib import EventRoleType, EventType, Person
from gramps.gen.utils.file import media_path_full
from gramps.gui.thumbnails import get_thumbnail_path
@ -60,11 +60,12 @@ from gramps.gen.datehandler import displayer as _dd
from gramps.gen.plug.report import Report
from gramps.gen.plug.report import utils as ReportUtils
from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions
from gramps.gen.plug.menu import (NumberOption, ColorOption, BooleanOption,
EnumeratedListOption, PersonListOption,
SurnameColorOption)
EnumeratedListOption, PersonListOption,
SurnameColorOption)
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.display.name import displayer as global_name_display
#------------------------------------------------------------------------
#
@ -111,7 +112,8 @@ class FamilyLinesOptions(MenuReportOptions):
def add_menu_options(self, menu):
# --------------------------------
add_option = partial(menu.add_option, _('People of Interest'))
category_name = _('People of Interest')
add_option = partial(menu.add_option, category_name)
# --------------------------------
person_list = PersonListOption(_('People of interest'))
@ -119,6 +121,8 @@ class FamilyLinesOptions(MenuReportOptions):
'point when determining "family lines".'))
add_option('gidlist', person_list)
stdoptions.add_name_format_option(menu, category_name)
followpar = BooleanOption(
_('Follow parents to determine family lines'), True)
followpar.set_help(_('Parents and their ancestors will be '
@ -349,6 +353,13 @@ class FamilyLinesReport(Report):
#option can be from another family tree, so person can be None
self._interest_set.add(person.get_handle())
# Copy the global NameDisplay so that we don't change application
# defaults.
self._name_display = copy.deepcopy(global_name_display)
name_format = menu.get_option_by_name("name_format").get_value()
if name_format != 0:
self._name_display.set_default_format(name_format)
# convert the 'surnamecolors' string to a dictionary of names and colors
self._surnamecolors = {}
tmp = get_value('surnamecolors')
@ -719,7 +730,7 @@ class FamilyLinesReport(Report):
# loop through all the people we need to output
for handle in self._people:
person = self._db.get_person_from_handle(handle)
name = name_displayer.display_name(person.get_primary_name())
name = self._name_display.display(person)
# figure out what colour to use
gender = person.get_gender()

View File

@ -4,7 +4,8 @@
# Copyright (C) 2007-2008 Brian G. Matherly
# Copyright (C) 2008 Stephane Charette <stephanecharette@gmail.com>
# Contribution 2009 by Bob Ham <rah@bash.sh>
# Copyright (C) 2010 Jakim Friant
# Copyright (C) 2010 Jakim Friant
# Copyright (C) 2013 Paul Franklin
#
# 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
@ -24,28 +25,29 @@
"""
Generate an hourglass graph using the GraphViz generator.
/Reports/GraphViz/Hourglass Graph
"""
#------------------------------------------------------------------------
#
# python modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import copy
#------------------------------------------------------------------------
#
# GRAMPS modules
#
#------------------------------------------------------------------------
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.display.name import displayer as global_name_display
from gramps.gen.errors import ReportError
from gramps.gen.plug.menu import (PersonOption, BooleanOption, NumberOption,
EnumeratedListOption)
EnumeratedListOption)
from gramps.gen.plug.report import Report
from gramps.gen.plug.report import utils as ReportUtils
from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions
from gramps.gen.datehandler import get_date
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
@ -108,6 +110,13 @@ class HourGlassReport(Report):
self.colors = filled
self.roundcorners = menu.get_option_by_name('roundcorners').get_value()
# Copy the global NameDisplay so that we don't change application
# defaults.
self._name_display = copy.deepcopy(global_name_display)
name_format = menu.get_option_by_name("name_format").get_value()
if name_format != 0:
self._name_display.set_default_format(name_format)
def write_report(self):
"""
Generate the report.
@ -172,7 +181,7 @@ class HourGlassReport(Report):
Add a person to the Graph. The node id will be the person's gramps id.
"""
p_id = person.get_gramps_id()
name = name_displayer.display_formal(person)
name = self._name_display.display(person)
birth_evt = get_birth_or_fallback(self.__db, person)
if birth_evt:
@ -263,6 +272,8 @@ class HourGlassOptions(MenuReportOptions):
pid.set_help(_("The Center person for the graph"))
menu.add_option(category_name, "pid", pid)
stdoptions.add_name_format_option(menu, category_name)
max_gen = NumberOption(_('Max Descendant Generations'), 10, 1, 15)
max_gen.set_help(_("The number of generations of descendants to "
"include in the graph"))

View File

@ -12,6 +12,7 @@
# Copyright (C) 2009 Gary Burton
# Contribution 2009 by Bob Ham <rah@bash.sh>
# Copyright (C) 2010 Jakim Friant
# Copyright (C) 2013 Paul Franklin
#
# 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
@ -42,6 +43,7 @@ Create a relationship graph using Graphviz
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from functools import partial
import copy
#------------------------------------------------------------------------
#
@ -49,12 +51,13 @@ from functools import partial
#
#------------------------------------------------------------------------
from gramps.gen.constfunc import conv_to_unicode
from gramps.gen.plug.menu import (BooleanOption, EnumeratedListOption, FilterOption,
PersonOption, ColorOption)
from gramps.gen.plug.menu import (BooleanOption, EnumeratedListOption,
FilterOption, PersonOption, ColorOption)
from gramps.gen.plug.report import Report
from gramps.gen.plug.report import utils as ReportUtils
from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.plug.report import stdoptions
from gramps.gen.display.name import displayer as global_name_display
from gramps.gen.datehandler import get_date
from gramps.gen.lib import ChildRefType, EventRoleType, EventType
from gramps.gen.utils.file import media_path_full, find_file
@ -160,6 +163,13 @@ class RelGraphReport(Report):
filter_option = get_option_by_name('filter')
self._filter = filter_option.get_filter()
# Copy the global NameDisplay so that we don't change application
# defaults.
self._name_display = copy.deepcopy(global_name_display)
name_format = menu.get_option_by_name("name_format").get_value()
if name_format != 0:
self._name_display.set_default_format(name_format)
def write_report(self):
self.person_handles = self._filter.apply(self.database,
self.database.iter_person_handles())
@ -392,7 +402,7 @@ class RelGraphReport(Report):
self.bUseHtmlOutput = False
# at the very least, the label must have the person's name
nm = name_displayer.display_name(person.get_primary_name())
nm = self._name_display.display(person)
if self.bUseHtmlOutput :
# avoid < and > in the name, as this is html text
label += nm.replace('<', '&#60;').replace('>', '&#62;')
@ -480,7 +490,8 @@ class RelGraphOptions(MenuReportOptions):
def add_menu_options(self, menu):
################################
add_option = partial(menu.add_option, _("Report Options"))
category_name = _("Report Options")
add_option = partial(menu.add_option, category_name)
################################
self.__filter = FilterOption(_("Filter"), 0)
@ -494,6 +505,8 @@ class RelGraphOptions(MenuReportOptions):
add_option("pid", self.__pid)
self.__pid.connect('value-changed', self.__update_filters)
stdoptions.add_name_format_option(menu, category_name)
self.__update_filters()
self.incdate = BooleanOption(