Update according to issue 1961
svn: r10527
This commit is contained in:
parent
3b4378fe81
commit
e6b386ef54
@ -35,12 +35,23 @@ from gettext import gettext as _
|
|||||||
# GRAMPS modules
|
# GRAMPS modules
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
from PluginUtils import register_report, NumberOption, PersonOption
|
from PluginUtils import register_report, NumberOption, PersonOption, \
|
||||||
|
EnumeratedListOption
|
||||||
from ReportBase import Report, ReportUtils, MenuReportOptions, \
|
from ReportBase import Report, ReportUtils, MenuReportOptions, \
|
||||||
MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ
|
MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ
|
||||||
from BasicUtils import name_displayer
|
from BasicUtils import name_displayer
|
||||||
import DateHandler
|
import DateHandler
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Constant options items
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
_COLORS = [ { 'name' : _("B&W outline"), 'value' : "outline" },
|
||||||
|
{ 'name' : _("Colored outline"), 'value' : "colored" },
|
||||||
|
{ 'name' : _("Color fill"), 'value' : "filled" }]
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# HourGlassReport
|
# HourGlassReport
|
||||||
@ -55,6 +66,20 @@ class HourGlassReport(Report):
|
|||||||
Create HourGlass object that produces the report.
|
Create HourGlass object that produces the report.
|
||||||
"""
|
"""
|
||||||
Report.__init__(self, database, options_class)
|
Report.__init__(self, database, options_class)
|
||||||
|
|
||||||
|
colored = {
|
||||||
|
'male': 'dodgerblue4',
|
||||||
|
'female': 'deeppink',
|
||||||
|
'unknown': 'black',
|
||||||
|
'family': 'darkgreen'
|
||||||
|
}
|
||||||
|
filled = {
|
||||||
|
'male': 'lightblue',
|
||||||
|
'female': 'lightpink',
|
||||||
|
'unknown': 'lightgray',
|
||||||
|
'family': 'lightyellow'
|
||||||
|
}
|
||||||
|
|
||||||
self.__db = database
|
self.__db = database
|
||||||
|
|
||||||
menu = options_class.menu
|
menu = options_class.menu
|
||||||
@ -62,6 +87,11 @@ class HourGlassReport(Report):
|
|||||||
self.max_ascend = menu.get_option_by_name('maxascend').get_value()
|
self.max_ascend = menu.get_option_by_name('maxascend').get_value()
|
||||||
pid = menu.get_option_by_name('pid').get_value()
|
pid = menu.get_option_by_name('pid').get_value()
|
||||||
self.center_person = database.get_person_from_gramps_id(pid)
|
self.center_person = database.get_person_from_gramps_id(pid)
|
||||||
|
self.colorize = menu.get_option_by_name('color').get_value()
|
||||||
|
if self.colorize == 'colored':
|
||||||
|
self.colors = colored
|
||||||
|
elif self.colorize == 'filled':
|
||||||
|
self.colors = filled
|
||||||
|
|
||||||
def write_report(self):
|
def write_report(self):
|
||||||
"""
|
"""
|
||||||
@ -80,12 +110,12 @@ class HourGlassReport(Report):
|
|||||||
for family_handle in person.get_family_handle_list():
|
for family_handle in person.get_family_handle_list():
|
||||||
family = self.__db.get_family_from_handle(family_handle)
|
family = self.__db.get_family_from_handle(family_handle)
|
||||||
self.add_family(family)
|
self.add_family(family)
|
||||||
self.doc.add_link( person.get_gramps_id(), family.get_gramps_id() )
|
self.doc.add_link( person.get_gramps_id(), family.get_gramps_id(), head='normal', tail='none' )
|
||||||
for child_ref in family.get_child_ref_list():
|
for child_ref in family.get_child_ref_list():
|
||||||
child_handle = child_ref.get_reference_handle()
|
child_handle = child_ref.get_reference_handle()
|
||||||
child = self.__db.get_person_from_handle(child_handle)
|
child = self.__db.get_person_from_handle(child_handle)
|
||||||
self.add_person(child)
|
self.add_person(child)
|
||||||
self.doc.add_link(family.get_gramps_id(), child.get_gramps_id())
|
self.doc.add_link(family.get_gramps_id(), child.get_gramps_id(), head='normal', tail='none' )
|
||||||
self.traverse_down(child, gen+1)
|
self.traverse_down(child, gen+1)
|
||||||
|
|
||||||
def traverse_up(self, person, gen):
|
def traverse_up(self, person, gen):
|
||||||
@ -99,18 +129,18 @@ class HourGlassReport(Report):
|
|||||||
family = self.__db.get_family_from_handle(family_handle)
|
family = self.__db.get_family_from_handle(family_handle)
|
||||||
family_id = family.get_gramps_id()
|
family_id = family.get_gramps_id()
|
||||||
self.add_family(family)
|
self.add_family(family)
|
||||||
self.doc.add_link( family_id, person.get_gramps_id() )
|
self.doc.add_link( family_id, person.get_gramps_id(), head='none', tail='normal' )
|
||||||
father_handle = family.get_father_handle()
|
father_handle = family.get_father_handle()
|
||||||
if father_handle:
|
if father_handle:
|
||||||
father = self.__db.get_person_from_handle(father_handle)
|
father = self.__db.get_person_from_handle(father_handle)
|
||||||
self.add_person(father)
|
self.add_person(father)
|
||||||
self.doc.add_link( father.get_gramps_id(), family_id )
|
self.doc.add_link( father.get_gramps_id(), family_id, head='none', tail='normal' )
|
||||||
self.traverse_up(father, gen+1)
|
self.traverse_up(father, gen+1)
|
||||||
mother_handle = family.get_mother_handle()
|
mother_handle = family.get_mother_handle()
|
||||||
if mother_handle:
|
if mother_handle:
|
||||||
mother = self.__db.get_person_from_handle( mother_handle )
|
mother = self.__db.get_person_from_handle( mother_handle )
|
||||||
self.add_person( mother )
|
self.add_person( mother )
|
||||||
self.doc.add_link( mother.get_gramps_id(), family_id )
|
self.doc.add_link( mother.get_gramps_id(), family_id, head='none', tail='normal' )
|
||||||
self.traverse_up( mother, gen+1 )
|
self.traverse_up( mother, gen+1 )
|
||||||
|
|
||||||
def add_person(self, person):
|
def add_person(self, person):
|
||||||
@ -134,15 +164,8 @@ class HourGlassReport(Report):
|
|||||||
|
|
||||||
label = "%s \\n(%s - %s)" % (name, birth, death)
|
label = "%s \\n(%s - %s)" % (name, birth, death)
|
||||||
|
|
||||||
gender = person.get_gender()
|
(shape, style, color, fill) = self.get_gender_style(person)
|
||||||
if gender == person.MALE:
|
self.doc.add_node(p_id, label, shape, color, style, fill)
|
||||||
color = 'lightblue'
|
|
||||||
elif gender == person.FEMALE:
|
|
||||||
color = 'lightpink'
|
|
||||||
else:
|
|
||||||
color = 'lightgray'
|
|
||||||
|
|
||||||
self.doc.add_node(p_id, label, "box", "", "filled", color)
|
|
||||||
|
|
||||||
def add_family(self, family):
|
def add_family(self, family):
|
||||||
"""
|
"""
|
||||||
@ -153,8 +176,51 @@ class HourGlassReport(Report):
|
|||||||
marriage = ReportUtils.find_marriage(self.__db, family)
|
marriage = ReportUtils.find_marriage(self.__db, family)
|
||||||
if marriage:
|
if marriage:
|
||||||
label = DateHandler.get_date(marriage)
|
label = DateHandler.get_date(marriage)
|
||||||
self.doc.add_node(family_id, label, "ellipse", "",
|
color = ""
|
||||||
"filled", "lightyellow")
|
fill = ""
|
||||||
|
style = "solid"
|
||||||
|
if self.colorize == 'colored':
|
||||||
|
color = self.colors['family']
|
||||||
|
elif self.colorize == 'filled':
|
||||||
|
fill = self.colors['family']
|
||||||
|
style = "filled"
|
||||||
|
self.doc.add_node(family_id, label, "ellipse", color, style, fill)
|
||||||
|
|
||||||
|
def get_gender_style(self, person):
|
||||||
|
"return gender specific person style"
|
||||||
|
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"
|
||||||
|
if self.colorize == 'colored':
|
||||||
|
if gender == person.MALE:
|
||||||
|
color = self.colors['male']
|
||||||
|
elif gender == person.FEMALE:
|
||||||
|
color = self.colors['female']
|
||||||
|
else:
|
||||||
|
color = self.colors['unknown']
|
||||||
|
elif self.colorize == 'filled':
|
||||||
|
if style != "":
|
||||||
|
style += ",filled"
|
||||||
|
else:
|
||||||
|
style = "filled"
|
||||||
|
if gender == person.MALE:
|
||||||
|
fill = self.colors['male']
|
||||||
|
elif gender == person.FEMALE:
|
||||||
|
fill = self.colors['female']
|
||||||
|
else:
|
||||||
|
fill = self.colors['unknown']
|
||||||
|
return(shape, style, color, fill)
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -175,7 +241,7 @@ class HourGlassOptions(MenuReportOptions):
|
|||||||
category_name = _("Options")
|
category_name = _("Options")
|
||||||
|
|
||||||
pid = PersonOption(_("Center Person"))
|
pid = PersonOption(_("Center Person"))
|
||||||
pid.set_help(_("The center person for the graph"))
|
pid.set_help(_("The Center person for the graph"))
|
||||||
menu.add_option(category_name, "pid", pid)
|
menu.add_option(category_name, "pid", pid)
|
||||||
|
|
||||||
max_gen = NumberOption(_('Max Descendant Generations'), 10, 1, 15)
|
max_gen = NumberOption(_('Max Descendant Generations'), 10, 1, 15)
|
||||||
@ -188,6 +254,19 @@ class HourGlassOptions(MenuReportOptions):
|
|||||||
"include in the graph"))
|
"include in the graph"))
|
||||||
menu.add_option(category_name, "maxascend", max_gen)
|
menu.add_option(category_name, "maxascend", max_gen)
|
||||||
|
|
||||||
|
################################
|
||||||
|
category_name = _("Graph Style")
|
||||||
|
################################
|
||||||
|
|
||||||
|
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. If the sex of an individual "
|
||||||
|
"is unknown it will be shown with gray."))
|
||||||
|
menu.add_option(category_name, "color", color)
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user