* src/plugins/GraphViz.py: Added option to limit dates to just years,
fixed bug to prevent family nodes from being listed more than once svn: r1951
This commit is contained in:
parent
8080269cc2
commit
ec11731de3
@ -148,14 +148,22 @@ class GraphVizDialog(Report.ReportDialog):
|
|||||||
self.arrowstyle_optionmenu,
|
self.arrowstyle_optionmenu,
|
||||||
_("Choose the direction that the arrows point."))
|
_("Choose the direction that the arrows point."))
|
||||||
|
|
||||||
msg = _("Include Birth and Death Dates")
|
msg = _("Include Birth, Marriage and Death Dates")
|
||||||
self.includedates_cb = gtk.CheckButton(msg)
|
self.includedates_cb = gtk.CheckButton(msg)
|
||||||
self.includedates_cb.set_active(1)
|
self.includedates_cb.set_active(1)
|
||||||
self.add_frame_option(_("GraphViz Options"), '',
|
self.add_frame_option(_("GraphViz Options"), '',
|
||||||
self.includedates_cb,
|
self.includedates_cb,
|
||||||
_("Include the years that the individual "
|
_("Include the dates that the individual "
|
||||||
"was born and/or died in the graph node "
|
"was born, got married and/or died "
|
||||||
"labels."))
|
"in the graph labels."))
|
||||||
|
|
||||||
|
self.just_year_cb = gtk.CheckButton(_("Limit dates to years only"))
|
||||||
|
self.just_year_cb.set_active(0)
|
||||||
|
self.add_frame_option(_("GraphViz Options"), '',
|
||||||
|
self.just_year_cb,
|
||||||
|
_("Prints just dates' year, neither "
|
||||||
|
"month or day nor date approximation "
|
||||||
|
"or interval are shown."))
|
||||||
|
|
||||||
self.includeurl_cb = gtk.CheckButton(_("Include URLs"))
|
self.includeurl_cb = gtk.CheckButton(_("Include URLs"))
|
||||||
self.includeurl_cb.set_active(1)
|
self.includeurl_cb.set_active(1)
|
||||||
@ -190,7 +198,7 @@ class GraphVizDialog(Report.ReportDialog):
|
|||||||
self.add_frame_option(_("GraphViz Options"),
|
self.add_frame_option(_("GraphViz Options"),
|
||||||
'',
|
'',
|
||||||
self.show_families_cb,
|
self.show_families_cb,
|
||||||
_("Families will show up as circles, linked "
|
_("Families will show up as ellipses, linked "
|
||||||
"to parents and children."))
|
"to parents and children."))
|
||||||
|
|
||||||
tb_margin_adj = gtk.Adjustment(value=0.5, lower=0.25,
|
tb_margin_adj = gtk.Adjustment(value=0.5, lower=0.25,
|
||||||
@ -268,6 +276,7 @@ class GraphVizDialog(Report.ReportDialog):
|
|||||||
self.hpages = self.hpages_sb.get_value_as_int()
|
self.hpages = self.hpages_sb.get_value_as_int()
|
||||||
self.vpages = self.vpages_sb.get_value_as_int()
|
self.vpages = self.vpages_sb.get_value_as_int()
|
||||||
self.show_families = self.show_families_cb.get_active()
|
self.show_families = self.show_families_cb.get_active()
|
||||||
|
self.just_year = self.just_year_cb.get_active()
|
||||||
|
|
||||||
def make_report(self):
|
def make_report(self):
|
||||||
"""Create the object that will produce the GraphViz file."""
|
"""Create the object that will produce the GraphViz file."""
|
||||||
@ -287,7 +296,7 @@ class GraphVizDialog(Report.ReportDialog):
|
|||||||
self.tb_margin, self.lr_margin, self.hpages,
|
self.tb_margin, self.lr_margin, self.hpages,
|
||||||
self.vpages, self.includedates, self.includeurl,
|
self.vpages, self.includedates, self.includeurl,
|
||||||
self.colorize, self.adoptionsdashed, self.arrowheadstyle,
|
self.colorize, self.adoptionsdashed, self.arrowheadstyle,
|
||||||
self.arrowtailstyle, self.show_families)
|
self.arrowtailstyle, self.show_families, self.just_year)
|
||||||
|
|
||||||
if self.print_report.get_active ():
|
if self.print_report.get_active ():
|
||||||
os.environ["DOT"] = self.target_path
|
os.environ["DOT"] = self.target_path
|
||||||
@ -310,7 +319,7 @@ def report(database,person):
|
|||||||
def write_dot(file, ind_list, orien, width, height, tb_margin,
|
def write_dot(file, ind_list, orien, width, height, tb_margin,
|
||||||
lr_margin, hpages, vpages, includedates, includeurl,
|
lr_margin, hpages, vpages, includedates, includeurl,
|
||||||
colorize, adoptionsdashed, arrowheadstyle, arrowtailstyle,
|
colorize, adoptionsdashed, arrowheadstyle, arrowtailstyle,
|
||||||
show_families):
|
show_families, just_year):
|
||||||
file.write("digraph g {\n")
|
file.write("digraph g {\n")
|
||||||
file.write("bgcolor=white;\n")
|
file.write("bgcolor=white;\n")
|
||||||
file.write("rankdir=LR;\n")
|
file.write("rankdir=LR;\n")
|
||||||
@ -326,7 +335,7 @@ def write_dot(file, ind_list, orien, width, height, tb_margin,
|
|||||||
|
|
||||||
if len(ind_list) > 1:
|
if len(ind_list) > 1:
|
||||||
dump_index(ind_list,file,includedates,includeurl,colorize,
|
dump_index(ind_list,file,includedates,includeurl,colorize,
|
||||||
arrowheadstyle,arrowtailstyle,show_families)
|
arrowheadstyle,arrowtailstyle,show_families,just_year)
|
||||||
dump_person(ind_list,file,adoptionsdashed,arrowheadstyle,
|
dump_person(ind_list,file,adoptionsdashed,arrowheadstyle,
|
||||||
arrowtailstyle,show_families)
|
arrowtailstyle,show_families)
|
||||||
|
|
||||||
@ -394,7 +403,7 @@ def dump_person(person_list,file,adoptionsdashed,arrowheadstyle,
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
def dump_index(person_list,file,includedates,includeurl,colorize,
|
def dump_index(person_list,file,includedates,includeurl,colorize,
|
||||||
arrowheadstyle,arrowtailstyle,show_families):
|
arrowheadstyle,arrowtailstyle,show_families,just_year):
|
||||||
# The list of families for which we have output the node, so we
|
# The list of families for which we have output the node, so we
|
||||||
# don't do it twice.
|
# don't do it twice.
|
||||||
families_done = []
|
families_done = []
|
||||||
@ -404,11 +413,17 @@ def dump_index(person_list,file,includedates,includeurl,colorize,
|
|||||||
id = string.replace(person.getId(),'-','_')
|
id = string.replace(person.getId(),'-','_')
|
||||||
if includedates:
|
if includedates:
|
||||||
if person.getBirth().getDateObj().getYearValid():
|
if person.getBirth().getDateObj().getYearValid():
|
||||||
|
if just_year:
|
||||||
birth = '%i' % person.getBirth().getDateObj().getYear()
|
birth = '%i' % person.getBirth().getDateObj().getYear()
|
||||||
|
else:
|
||||||
|
birth = person.getBirth().getDate()
|
||||||
else:
|
else:
|
||||||
birth = ''
|
birth = ''
|
||||||
if person.getDeath().getDateObj().getYearValid():
|
if person.getDeath().getDateObj().getYearValid():
|
||||||
|
if just_year:
|
||||||
death = '%i' % person.getDeath().getDateObj().getYear()
|
death = '%i' % person.getDeath().getDateObj().getYear()
|
||||||
|
else:
|
||||||
|
death = person.getDeath().getDate()
|
||||||
else:
|
else:
|
||||||
death = ''
|
death = ''
|
||||||
label = label + '\\n(%s - %s)' % (birth, death)
|
label = label + '\\n(%s - %s)' % (birth, death)
|
||||||
@ -430,8 +445,19 @@ def dump_index(person_list,file,includedates,includeurl,colorize,
|
|||||||
for fam in family_list:
|
for fam in family_list:
|
||||||
fid = string.replace(fam.getId(),'-','_')
|
fid = string.replace(fam.getId(),'-','_')
|
||||||
if fam not in families_done:
|
if fam not in families_done:
|
||||||
file.write('f%s [shape=circle, label="", ' % fid)
|
families_done.append(fam)
|
||||||
file.write('weight=8, height=.3];\n')
|
file.write('f%s [shape=ellipse, ' % fid)
|
||||||
|
marriage = ""
|
||||||
|
m = fam.getMarriage()
|
||||||
|
if m != None:
|
||||||
|
do = m.getDateObj()
|
||||||
|
if do != None:
|
||||||
|
if do.getYearValid():
|
||||||
|
if just_year:
|
||||||
|
marriage = '%i' % date.getYear()
|
||||||
|
else:
|
||||||
|
marriage = m.getDate()
|
||||||
|
file.write('fontname="Arial", label="%s"];\n' % marriage)
|
||||||
# Link this person to all his/her families.
|
# Link this person to all his/her families.
|
||||||
file.write('f%s -> p%s [' % (fid, id))
|
file.write('f%s -> p%s [' % (fid, id))
|
||||||
file.write('arrowhead=%s, arrowtail=%s, ' %
|
file.write('arrowhead=%s, arrowtail=%s, ' %
|
||||||
|
Loading…
Reference in New Issue
Block a user