6818: Enable Relationships support on RelationshipGraph (GraphViz)
svn: r22636
This commit is contained in:
parent
e0637934ac
commit
c116049f2f
@ -12,6 +12,7 @@
|
|||||||
# Copyright (C) 2009 Gary Burton
|
# Copyright (C) 2009 Gary Burton
|
||||||
# Contribution 2009 by Bob Ham <rah@bash.sh>
|
# Contribution 2009 by Bob Ham <rah@bash.sh>
|
||||||
# Copyright (C) 2010 Jakim Friant
|
# Copyright (C) 2010 Jakim Friant
|
||||||
|
# Copyright (C) 2013 Fedir Zinchuk <fedikw@gmail.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -57,6 +58,7 @@ import DateHandler
|
|||||||
import gen.lib
|
import gen.lib
|
||||||
import Utils
|
import Utils
|
||||||
import ThumbNails
|
import ThumbNails
|
||||||
|
import Relationship
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -158,6 +160,17 @@ class RelGraphReport(Report):
|
|||||||
filter_option = get_option_by_name('filter')
|
filter_option = get_option_by_name('filter')
|
||||||
self._filter = filter_option.get_filter()
|
self._filter = filter_option.get_filter()
|
||||||
|
|
||||||
|
self.center_person = database.get_person_from_gramps_id(
|
||||||
|
get_value('pid'))
|
||||||
|
self.increlname = get_value('increlname')
|
||||||
|
if self.increlname :
|
||||||
|
self.rel_calc = Relationship.get_relationship_calculator()
|
||||||
|
|
||||||
|
if __debug__:
|
||||||
|
self.advrelinfo = get_value('advrelinfo')
|
||||||
|
else:
|
||||||
|
self.advrelinfo = False
|
||||||
|
|
||||||
def write_report(self):
|
def write_report(self):
|
||||||
self.person_handles = self._filter.apply(self.database,
|
self.person_handles = self._filter.apply(self.database,
|
||||||
self.database.iter_person_handles())
|
self.database.iter_person_handles())
|
||||||
@ -326,6 +339,9 @@ class RelGraphReport(Report):
|
|||||||
elif gender == person.UNKNOWN:
|
elif gender == person.UNKNOWN:
|
||||||
shape = "hexagon"
|
shape = "hexagon"
|
||||||
|
|
||||||
|
if person == self.center_person and self.increlname:
|
||||||
|
shape = "octagon"
|
||||||
|
|
||||||
if self.colorize == 'colored':
|
if self.colorize == 'colored':
|
||||||
if gender == person.MALE:
|
if gender == person.MALE:
|
||||||
color = self.colors['male']
|
color = self.colors['male']
|
||||||
@ -402,6 +418,20 @@ class RelGraphReport(Report):
|
|||||||
birth, death = self.get_date_strings(person)
|
birth, death = self.get_date_strings(person)
|
||||||
label = label + '%s(%s - %s)' % (lineDelimiter, birth, death)
|
label = label + '%s(%s - %s)' % (lineDelimiter, birth, death)
|
||||||
|
|
||||||
|
if self.increlname and self.center_person != person:
|
||||||
|
# display relationship info
|
||||||
|
if self.advrelinfo:
|
||||||
|
(relationship, Ga, Gb) = self.rel_calc.get_one_relationship(
|
||||||
|
self.database, self.center_person, person, True)
|
||||||
|
if relationship:
|
||||||
|
label += "%s(%s Ga=%d Gb=%d)" % (lineDelimiter,
|
||||||
|
relationship, Ga, Gb)
|
||||||
|
else:
|
||||||
|
relationship = self.rel_calc.get_one_relationship(
|
||||||
|
self.database, self.center_person, person)
|
||||||
|
if relationship:
|
||||||
|
label += "%s(%s)" % (lineDelimiter, relationship)
|
||||||
|
|
||||||
# see if we have a table that needs to be terminated
|
# see if we have a table that needs to be terminated
|
||||||
if self.bUseHtmlOutput:
|
if self.bUseHtmlOutput:
|
||||||
label += '</TD></TR></TABLE>'
|
label += '</TD></TR></TABLE>'
|
||||||
@ -463,6 +493,8 @@ class RelGraphOptions(MenuReportOptions):
|
|||||||
def __init__(self, name, dbase):
|
def __init__(self, name, dbase):
|
||||||
self.__pid = None
|
self.__pid = None
|
||||||
self.__filter = None
|
self.__filter = None
|
||||||
|
self.__show_relships = None
|
||||||
|
self.__show_GaGb = None
|
||||||
self.__include_images = None
|
self.__include_images = None
|
||||||
self.__image_on_side = None
|
self.__image_on_side = None
|
||||||
self.__db = dbase
|
self.__db = dbase
|
||||||
@ -479,8 +511,8 @@ class RelGraphOptions(MenuReportOptions):
|
|||||||
add_option("filter", self.__filter)
|
add_option("filter", self.__filter)
|
||||||
self.__filter.connect('value-changed', self.__filter_changed)
|
self.__filter.connect('value-changed', self.__filter_changed)
|
||||||
|
|
||||||
self.__pid = PersonOption(_("Filter Person"))
|
self.__pid = PersonOption(_("Center Person"))
|
||||||
self.__pid.set_help(_("The center person for the filter"))
|
self.__pid.set_help(_("The center person for the report"))
|
||||||
add_option("pid", self.__pid)
|
add_option("pid", self.__pid)
|
||||||
self.__pid.connect('value-changed', self.__update_filters)
|
self.__pid.connect('value-changed', self.__update_filters)
|
||||||
|
|
||||||
@ -517,6 +549,22 @@ class RelGraphOptions(MenuReportOptions):
|
|||||||
incid.set_help(_("Include individual and family IDs."))
|
incid.set_help(_("Include individual and family IDs."))
|
||||||
add_option("incid", incid)
|
add_option("incid", incid)
|
||||||
|
|
||||||
|
self.__show_relships = BooleanOption(
|
||||||
|
_("Include relationship to center person"), False)
|
||||||
|
self.__show_relships.set_help(_("Whether to show every "
|
||||||
|
"person's relationship to the center person"))
|
||||||
|
add_option("increlname", self.__show_relships)
|
||||||
|
self.__show_relships.connect('value-changed',
|
||||||
|
self.__show_relships_changed)
|
||||||
|
|
||||||
|
if __debug__:
|
||||||
|
self.__show_GaGb = BooleanOption(_("Include relationship "
|
||||||
|
"debugging numbers also"),
|
||||||
|
False)
|
||||||
|
self.__show_GaGb.set_help(_("Whether to include 'Ga' and 'Gb' "
|
||||||
|
"also, to debug the relationship calculator"))
|
||||||
|
add_option("advrelinfo", self.__show_GaGb)
|
||||||
|
|
||||||
self.__include_images = BooleanOption(
|
self.__include_images = BooleanOption(
|
||||||
_('Include thumbnail images of people'), False)
|
_('Include thumbnail images of people'), False)
|
||||||
self.__include_images.set_help(
|
self.__include_images.set_help(
|
||||||
@ -613,6 +661,8 @@ class RelGraphOptions(MenuReportOptions):
|
|||||||
if filter_value in [1, 2, 3, 4]:
|
if filter_value in [1, 2, 3, 4]:
|
||||||
# Filters 1, 2, 3 and 4 rely on the center person
|
# Filters 1, 2, 3 and 4 rely on the center person
|
||||||
self.__pid.set_available(True)
|
self.__pid.set_available(True)
|
||||||
|
elif self.__show_relships and self.__show_relships.get_value():
|
||||||
|
self.__pid.set_available(True)
|
||||||
else:
|
else:
|
||||||
# The rest don't
|
# The rest don't
|
||||||
self.__pid.set_available(False)
|
self.__pid.set_available(False)
|
||||||
@ -623,3 +673,11 @@ class RelGraphOptions(MenuReportOptions):
|
|||||||
image location option unavailable.
|
image location option unavailable.
|
||||||
"""
|
"""
|
||||||
self.__image_on_side.set_available(self.__include_images.get_value())
|
self.__image_on_side.set_available(self.__include_images.get_value())
|
||||||
|
|
||||||
|
def __show_relships_changed(self):
|
||||||
|
"""
|
||||||
|
Enable/disable menu items if relationships are required
|
||||||
|
"""
|
||||||
|
if self.__show_GaGb:
|
||||||
|
self.__show_GaGb.set_available(self.__show_relships.get_value())
|
||||||
|
self.__filter_changed()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user