7541: Add places in rel_graph
This commit is contained in:
parent
8ac6617e71
commit
7be52a96fd
@ -11,8 +11,8 @@
|
|||||||
# 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-2014 Paul Franklin
|
|
||||||
# Copyright (C) 2013 Fedir Zinchuk <fedikw@gmail.com>
|
# Copyright (C) 2013 Fedir Zinchuk <fedikw@gmail.com>
|
||||||
|
# Copyright (C) 2013-2015 Paul Franklin
|
||||||
#
|
#
|
||||||
# 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
|
||||||
@ -54,7 +54,6 @@ from gramps.gen.plug.report import Report
|
|||||||
from gramps.gen.plug.report import utils as ReportUtils
|
from gramps.gen.plug.report import utils as ReportUtils
|
||||||
from gramps.gen.plug.report import MenuReportOptions
|
from gramps.gen.plug.report import MenuReportOptions
|
||||||
from gramps.gen.plug.report import stdoptions
|
from gramps.gen.plug.report import stdoptions
|
||||||
from gramps.gen.datehandler import get_date
|
|
||||||
from gramps.gen.lib import ChildRefType, EventRoleType, EventType
|
from gramps.gen.lib import ChildRefType, EventRoleType, EventType
|
||||||
from gramps.gen.utils.file import media_path_full, find_file
|
from gramps.gen.utils.file import media_path_full, find_file
|
||||||
from gramps.gui.thumbnails import get_thumbnail_path
|
from gramps.gui.thumbnails import get_thumbnail_path
|
||||||
@ -102,9 +101,6 @@ class RelGraphReport(Report):
|
|||||||
arrow - Arrow styles for heads and tails.
|
arrow - Arrow styles for heads and tails.
|
||||||
showfamily - Whether to show family nodes.
|
showfamily - Whether to show family nodes.
|
||||||
incid - Whether to include IDs.
|
incid - Whether to include IDs.
|
||||||
incdate - Whether to include dates.
|
|
||||||
justyears - Use years only.
|
|
||||||
use_place - Whether to replace missing dates with place
|
|
||||||
url - Whether to include URLs.
|
url - Whether to include URLs.
|
||||||
inclimg - Include images or not
|
inclimg - Include images or not
|
||||||
imgpos - Image position, above/beside name
|
imgpos - Image position, above/beside name
|
||||||
@ -118,6 +114,7 @@ class RelGraphReport(Report):
|
|||||||
use_roundedcorners - Whether to use rounded corners for females
|
use_roundedcorners - Whether to use rounded corners for females
|
||||||
name_format - Preferred format to display names
|
name_format - Preferred format to display names
|
||||||
incl_private - Whether to include private data
|
incl_private - Whether to include private data
|
||||||
|
event_choice - Whether to include dates and/or places
|
||||||
"""
|
"""
|
||||||
Report.__init__(self, database, options, user)
|
Report.__init__(self, database, options, user)
|
||||||
|
|
||||||
@ -128,16 +125,14 @@ class RelGraphReport(Report):
|
|||||||
stdoptions.run_private_data_option(self, menu)
|
stdoptions.run_private_data_option(self, menu)
|
||||||
|
|
||||||
self.includeid = get_value('incid')
|
self.includeid = get_value('incid')
|
||||||
self.includedates = get_value('incdate')
|
|
||||||
self.includeurl = get_value('url')
|
self.includeurl = get_value('url')
|
||||||
self.includeimg = get_value('includeImages')
|
self.includeimg = get_value('includeImages')
|
||||||
self.imgpos = get_value('imageOnTheSide')
|
self.imgpos = get_value('imageOnTheSide')
|
||||||
self.use_roundedcorners = get_value('useroundedcorners')
|
self.use_roundedcorners = get_value('useroundedcorners')
|
||||||
self.adoptionsdashed = get_value('dashed')
|
self.adoptionsdashed = get_value('dashed')
|
||||||
self.show_families = get_value('showfamily')
|
self.show_families = get_value('showfamily')
|
||||||
self.just_years = get_value('justyears')
|
|
||||||
self.use_place = get_value('use_place')
|
|
||||||
self.use_subgraphs = get_value('usesubgraphs')
|
self.use_subgraphs = get_value('usesubgraphs')
|
||||||
|
self.event_choice = get_value('event_choice')
|
||||||
|
|
||||||
self.colorize = get_value('color')
|
self.colorize = get_value('color')
|
||||||
color_males = get_value('colormales')
|
color_males = get_value('colormales')
|
||||||
@ -292,28 +287,47 @@ class RelGraphReport(Report):
|
|||||||
def __add_family(self, fam_handle):
|
def __add_family(self, fam_handle):
|
||||||
"""Add a node for a family and optionally link the spouses to it"""
|
"""Add a node for a family and optionally link the spouses to it"""
|
||||||
fam = self.database.get_family_from_handle(fam_handle)
|
fam = self.database.get_family_from_handle(fam_handle)
|
||||||
if fam is None: # perhaps from privacy proxy
|
if fam is None:
|
||||||
return
|
return
|
||||||
fam_id = fam.get_gramps_id()
|
fam_id = fam.get_gramps_id()
|
||||||
|
|
||||||
label = ""
|
date_label = place_label = None
|
||||||
for event_ref in fam.get_event_ref_list():
|
for event_ref in fam.get_event_ref_list():
|
||||||
event = self.database.get_event_from_handle(event_ref.ref)
|
event = self.database.get_event_from_handle(event_ref.ref)
|
||||||
if event is None: # perhaps from privacy proxy
|
if event is None:
|
||||||
continue
|
continue
|
||||||
if event.type == EventType.MARRIAGE and \
|
if (event.type == EventType.MARRIAGE and
|
||||||
(event_ref.get_role() == EventRoleType.FAMILY or
|
(event_ref.get_role() == EventRoleType.FAMILY or
|
||||||
event_ref.get_role() == EventRoleType.PRIMARY):
|
event_ref.get_role() == EventRoleType.PRIMARY)
|
||||||
label = self.get_event_string(event)
|
):
|
||||||
|
date_label = self.get_date_string(event)
|
||||||
|
if not (self.event_choice == 3 and date_label):
|
||||||
|
place_label = self.get_place_string(event)
|
||||||
break
|
break
|
||||||
if self.includeid == 1 and label: # same line
|
if self.includeid == 0 and not date_label and not place_label:
|
||||||
label = "%s (%s)" % (label, fam_id)
|
label = ""
|
||||||
elif self.includeid == 1 and not label:
|
elif self.includeid == 0 and not date_label and place_label:
|
||||||
|
label = "(%s)" % place_label
|
||||||
|
elif self.includeid == 0 and date_label and not place_label:
|
||||||
|
label = "(%s)" % date_label
|
||||||
|
elif self.includeid == 0 and date_label and place_label:
|
||||||
|
label = "(%s)\\n(%s)" % (date_label, place_label)
|
||||||
|
elif self.includeid == 1 and not date_label and not place_label:
|
||||||
label = "(%s)" % fam_id
|
label = "(%s)" % fam_id
|
||||||
elif self.includeid == 2 and label: # own line
|
elif self.includeid == 1 and not date_label and place_label:
|
||||||
label = "%s\\n(%s)" % (label, fam_id)
|
label = "(%s) (%s)" % (fam_id, place_label) # id on same line
|
||||||
elif self.includeid == 2 and not label:
|
elif self.includeid == 1 and date_label and not place_label:
|
||||||
|
label = "(%s) (%s)" % (fam_id, date_label) # id on same line
|
||||||
|
elif self.includeid == 1 and date_label and place_label:
|
||||||
|
label = "(%s) (%s)\\n(%s)" % (fam_id, date_label, place_label)
|
||||||
|
elif self.includeid == 2 and not date_label and not place_label:
|
||||||
label = "(%s)" % fam_id
|
label = "(%s)" % fam_id
|
||||||
|
elif self.includeid == 2 and not date_label and place_label:
|
||||||
|
label = "(%s)\\n(%s)" % (fam_id, place_label) # id on own line
|
||||||
|
elif self.includeid == 2 and date_label and not place_label:
|
||||||
|
label = "(%s)\\n(%s)" % (fam_id, date_label) # id on own line
|
||||||
|
elif self.includeid == 2 and date_label and place_label:
|
||||||
|
label = "(%s)\\n(%s)\\n(%s)" % (fam_id, date_label, place_label)
|
||||||
color = ""
|
color = ""
|
||||||
fill = ""
|
fill = ""
|
||||||
style = "solid"
|
style = "solid"
|
||||||
@ -436,16 +450,27 @@ class RelGraphReport(Report):
|
|||||||
if self.includeid == 1: # same line
|
if self.includeid == 1: # same line
|
||||||
label += " (%s)" % p_id
|
label += " (%s)" % p_id
|
||||||
elif self.includeid == 2: # own line
|
elif self.includeid == 2: # own line
|
||||||
label = "%s%s(%s)" % (label, lineDelimiter, p_id)
|
label += "%s(%s)" % (lineDelimiter, p_id)
|
||||||
if self.includedates:
|
if self.event_choice != 0:
|
||||||
birth, death = self.get_date_strings(person)
|
b_date, d_date, b_place, d_place = self.get_event_strings(person)
|
||||||
if birth or death:
|
if self.event_choice in [1, 2, 3, 4, 5] and (b_date or d_date):
|
||||||
label += '%s(' % lineDelimiter
|
label += '%s(' % lineDelimiter
|
||||||
if birth:
|
if b_date:
|
||||||
label += '%s' % birth
|
label += '%s' % b_date
|
||||||
label += ' - '
|
label += ' - '
|
||||||
if death:
|
if d_date:
|
||||||
label += '%s' % death
|
label += '%s' % d_date
|
||||||
|
label += ')'
|
||||||
|
if (self.event_choice in [2, 3, 5, 6] and
|
||||||
|
(b_place or d_place) and
|
||||||
|
not (self.event_choice == 3 and (b_date or d_date))
|
||||||
|
):
|
||||||
|
label += '%s(' % lineDelimiter
|
||||||
|
if b_place:
|
||||||
|
label += '%s' % b_place
|
||||||
|
label += ' - '
|
||||||
|
if d_place:
|
||||||
|
label += '%s' % d_place
|
||||||
label += ')'
|
label += ')'
|
||||||
|
|
||||||
if self.increlname and self.center_person != person:
|
if self.increlname and self.center_person != person:
|
||||||
@ -472,41 +497,53 @@ class RelGraphReport(Report):
|
|||||||
# non html label is enclosed by "" so escape other "
|
# non html label is enclosed by "" so escape other "
|
||||||
return label.replace('"', '\\\"')
|
return label.replace('"', '\\\"')
|
||||||
|
|
||||||
def get_date_strings(self, person):
|
def get_event_strings(self, person):
|
||||||
"returns tuple of birth/christening and death/burying date strings"
|
"returns tuple of birth/christening and death/burying date strings"
|
||||||
|
|
||||||
|
birth_date = birth_place = death_date = death_place = ""
|
||||||
|
|
||||||
birth_event = get_birth_or_fallback(self.database, person)
|
birth_event = get_birth_or_fallback(self.database, person)
|
||||||
if birth_event:
|
if birth_event:
|
||||||
birth = self.get_event_string(birth_event)
|
birth_date = self.get_date_string(birth_event)
|
||||||
else:
|
birth_place = self.get_place_string(birth_event)
|
||||||
birth = ""
|
|
||||||
|
|
||||||
death_event = get_death_or_fallback(self.database, person)
|
death_event = get_death_or_fallback(self.database, person)
|
||||||
if death_event:
|
if death_event:
|
||||||
death = self.get_event_string(death_event)
|
death_date = self.get_date_string(death_event)
|
||||||
else:
|
death_place = self.get_place_string(death_event)
|
||||||
death = ""
|
|
||||||
|
|
||||||
return (birth, death)
|
return (birth_date, death_date, birth_place, death_place)
|
||||||
|
|
||||||
def get_event_string(self, event):
|
def get_date_string(self, event):
|
||||||
"""
|
"""
|
||||||
return string for for an event label.
|
return date string for an event label.
|
||||||
|
|
||||||
Based on the data availability and preferences, we select one
|
Based on the data availability and preferences, we select one
|
||||||
of the following for a given event:
|
of the following for a given event:
|
||||||
year only
|
year only
|
||||||
complete date
|
complete date
|
||||||
|
empty string
|
||||||
|
"""
|
||||||
|
if event and event.get_date_object() is not None:
|
||||||
|
event_date = event.get_date_object()
|
||||||
|
if event_date.get_year_valid():
|
||||||
|
if self.event_choice in [4, 5]:
|
||||||
|
return '%i' % event_date.get_year()
|
||||||
|
elif self.event_choice in [1, 2, 3]:
|
||||||
|
return self._get_date(event_date)
|
||||||
|
return ''
|
||||||
|
|
||||||
|
def get_place_string(self, event):
|
||||||
|
"""
|
||||||
|
return place string for an event label.
|
||||||
|
|
||||||
|
Based on the data availability and preferences, we select one
|
||||||
|
of the following for a given event:
|
||||||
place name
|
place name
|
||||||
empty string
|
empty string
|
||||||
"""
|
"""
|
||||||
if event:
|
if event and self.event_choice in [2, 3, 5, 6]:
|
||||||
if event.get_date_object().get_year_valid():
|
return place_displayer.display_event(self.database, event)
|
||||||
if self.just_years:
|
|
||||||
return '%i' % event.get_date_object().get_year()
|
|
||||||
elif self.includedates:
|
|
||||||
return self._get_date(event.get_date_object())
|
|
||||||
elif self.use_place:
|
|
||||||
return place_displayer.display_event(self.database, event)
|
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -558,25 +595,23 @@ class RelGraphOptions(MenuReportOptions):
|
|||||||
add_option = partial(menu.add_option, _("Include"))
|
add_option = partial(menu.add_option, _("Include"))
|
||||||
################################
|
################################
|
||||||
|
|
||||||
self.incdate = BooleanOption(
|
self.event_choice = EnumeratedListOption(_('Dates and/or Places'), 0)
|
||||||
_("Include Birth, Marriage and Death dates"), True)
|
self.event_choice.add_item(0, _('Do not include any dates or places'))
|
||||||
self.incdate.set_help(_("Include the dates that the individual was "
|
self.event_choice.add_item(1, _('Include (birth, marriage, death) '
|
||||||
"born, got married and/or died in the graph labels."))
|
'dates, but no places'))
|
||||||
add_option("incdate", self.incdate)
|
self.event_choice.add_item(2, _('Include (birth, marriage, death) '
|
||||||
self.incdate.connect('value-changed', self.__include_dates_changed)
|
'dates, and places'))
|
||||||
|
self.event_choice.add_item(3, _('Include (birth, marriage, death) '
|
||||||
self.justyears = BooleanOption(_("Limit dates to years only"), False)
|
'dates, and places if no dates'))
|
||||||
self.justyears.set_help(_("Prints just dates' year, neither "
|
self.event_choice.add_item(4, _('Include (birth, marriage, death) '
|
||||||
"month or day nor date approximation "
|
'years, but no places'))
|
||||||
"or interval are shown."))
|
self.event_choice.add_item(5, _('Include (birth, marriage, death) '
|
||||||
add_option("justyears", self.justyears)
|
'years, and places'))
|
||||||
|
self.event_choice.add_item(6, _('Include (birth, marriage, death) '
|
||||||
use_place = BooleanOption(_("Use place when no date"), True)
|
'places, but no dates'))
|
||||||
use_place.set_help(_("When no birth, marriage, or death date is "
|
self.event_choice.set_help(_("Whether to include dates and/or places"))
|
||||||
"available, the correspondent place field "
|
add_option("event_choice", self.event_choice)
|
||||||
"will be used."))
|
|
||||||
add_option("use_place", use_place)
|
|
||||||
|
|
||||||
url = BooleanOption(_("Include URLs"), False)
|
url = BooleanOption(_("Include URLs"), False)
|
||||||
url.set_help(_("Include a URL in each graph node so "
|
url.set_help(_("Include a URL in each graph node so "
|
||||||
"that PDF and imagemap files can be "
|
"that PDF and imagemap files can be "
|
||||||
@ -689,15 +724,6 @@ class RelGraphOptions(MenuReportOptions):
|
|||||||
name_format=nfv)
|
name_format=nfv)
|
||||||
self.__filter.set_filters(filter_list)
|
self.__filter.set_filters(filter_list)
|
||||||
|
|
||||||
def __include_dates_changed(self):
|
|
||||||
"""
|
|
||||||
Enable/disable menu items if dates are required
|
|
||||||
"""
|
|
||||||
if self.incdate.get_value():
|
|
||||||
self.justyears.set_available(True)
|
|
||||||
else:
|
|
||||||
self.justyears.set_available(False)
|
|
||||||
|
|
||||||
def __filter_changed(self):
|
def __filter_changed(self):
|
||||||
"""
|
"""
|
||||||
Handle filter change. If the filter is not specific to a person,
|
Handle filter change. If the filter is not specific to a person,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user