From c116049f2f60ea53c2571d89829854d69e211865 Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Mon, 1 Jul 2013 16:56:22 +0000 Subject: [PATCH] 6818: Enable Relationships support on RelationshipGraph (GraphViz) svn: r22636 --- src/plugins/graph/GVRelGraph.py | 62 +++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/src/plugins/graph/GVRelGraph.py b/src/plugins/graph/GVRelGraph.py index ed8cc10d2..f1aff94be 100644 --- a/src/plugins/graph/GVRelGraph.py +++ b/src/plugins/graph/GVRelGraph.py @@ -12,6 +12,7 @@ # Copyright (C) 2009 Gary Burton # Contribution 2009 by Bob Ham # Copyright (C) 2010 Jakim Friant +# Copyright (C) 2013 Fedir Zinchuk # # 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 @@ -57,6 +58,7 @@ import DateHandler import gen.lib import Utils import ThumbNails +import Relationship 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') 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): self.person_handles = self._filter.apply(self.database, self.database.iter_person_handles()) @@ -326,6 +339,9 @@ class RelGraphReport(Report): elif gender == person.UNKNOWN: shape = "hexagon" + if person == self.center_person and self.increlname: + shape = "octagon" + if self.colorize == 'colored': if gender == person.MALE: color = self.colors['male'] @@ -402,6 +418,20 @@ class RelGraphReport(Report): birth, death = self.get_date_strings(person) 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 if self.bUseHtmlOutput: label += '' @@ -463,6 +493,8 @@ class RelGraphOptions(MenuReportOptions): def __init__(self, name, dbase): self.__pid = None self.__filter = None + self.__show_relships = None + self.__show_GaGb = None self.__include_images = None self.__image_on_side = None self.__db = dbase @@ -479,8 +511,8 @@ class RelGraphOptions(MenuReportOptions): add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) - self.__pid = PersonOption(_("Filter Person")) - self.__pid.set_help(_("The center person for the filter")) + self.__pid = PersonOption(_("Center Person")) + self.__pid.set_help(_("The center person for the report")) add_option("pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) @@ -517,6 +549,22 @@ class RelGraphOptions(MenuReportOptions): incid.set_help(_("Include individual and family IDs.")) 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( _('Include thumbnail images of people'), False) self.__include_images.set_help( @@ -613,6 +661,8 @@ class RelGraphOptions(MenuReportOptions): if filter_value in [1, 2, 3, 4]: # Filters 1, 2, 3 and 4 rely on the center person self.__pid.set_available(True) + elif self.__show_relships and self.__show_relships.get_value(): + self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False) @@ -623,3 +673,11 @@ class RelGraphOptions(MenuReportOptions): image location option unavailable. """ 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()