GraphViz enhancements from Jeff Ollie

svn: r871
This commit is contained in:
Don Allingham 2002-03-29 00:56:28 +00:00
parent a79bd1954c
commit 39c36fb539
3 changed files with 92 additions and 22 deletions

View File

@ -92,7 +92,10 @@ class ChooseParents:
self.mother_rel.set_text(_("Birth"))
self.father_rel.set_text(_("Birth"))
self.type = self.family.getRelationship()
if self.family:
self.type = self.family.getRelationship()
else:
self.type = "Married"
self.prel.set_text(_(self.type))
self.redraw()

View File

@ -581,8 +581,8 @@ class ReportDialog:
self.pagecount_menu = GtkOptionMenu()
myMenu = Utils.build_string_optmenu(pagecount_map, start_text)
self.pagecount_menu.set_menu(myMenu)
table.attach(GtkLabel(_("Page Count")),2,1,3,2,FILL,FILL,pad,pad)
table.attach(self.pagecount_menu,3,2,4,2,xpadding=pad,ypadding=pad)
table.attach(GtkLabel(_("Page Count")),0,1,1,2,FILL,FILL,pad,pad)
table.attach(self.pagecount_menu,1,2,1,2,xpadding=pad,ypadding=pad)
def html_file_enable(self,obj):
text = obj.get_text()

View File

@ -21,6 +21,8 @@
"Generate files/Relationship graph"
import os
import string
import intl
import Utils
@ -146,6 +148,53 @@ class GraphVizDialog(ReportDialog):
"""Set up the list of possible content filters."""
return filter_map.keys()
def add_user_options(self):
self.arrowhead_optionmenu = GtkOptionMenu()
menu = GtkMenu()
menuitem = GtkMenuItem(_("Descendants <- Ancestors"))
menuitem.set_data('i', '[arrowhead=none, arrowtail=normal]')
menuitem.show()
menu.append(menuitem)
menuitem = GtkMenuItem(_("Descendants -> Ancestors"))
menuitem.set_data('i', '[arrowhead=normal, arrowtail=none]')
menuitem.show()
menu.append(menuitem)
menuitem = GtkMenuItem(_("Descendants <-> Ancestors"))
menuitem.set_data('i', '[arrowhead=normal, arrowtail=normal]')
menuitem.show()
menu.append(menuitem)
menu.set_active(0)
self.arrowhead_optionmenu.set_menu(menu)
tip = GtkTooltips()
tip.set_tip(self.arrowhead_optionmenu, _("Choose the direction that the arrows point."))
self.add_frame_option(_("GraphViz Options"), _("Arrowhead Options"), self.arrowhead_optionmenu)
self.includedates_checkbutton = GtkCheckButton(_("Include Birth and Death Dates"))
self.includedates_checkbutton.set_active(1)
tip = GtkTooltips()
tip.set_tip(self.includedates_checkbutton, _("Include the years that the individual was born and/or died in the graph node labels."))
self.add_frame_option(_("GraphViz Options"), ' ', self.includedates_checkbutton)
self.includeurl_checkbutton = GtkCheckButton(_("Include URLs"))
self.includeurl_checkbutton.set_active(1)
tip = GtkTooltips()
tip.set_tip(self.includeurl_checkbutton, _("Include a URL in each graph node so that PDF and imagemap files can be generated that contain active links to the files generated by the 'Generate Web Site' report."))
self.add_frame_option(_("GraphViz Options"), ' ', self.includeurl_checkbutton)
self.tb_margin_adjustment = GtkAdjustment(value=0.5, lower=0.25, upper=100.0, step_incr=0.25)
self.lr_margin_adjustment = GtkAdjustment(value=0.5, lower=0.25, upper=100.0, step_incr=0.25)
self.tb_margin_spinbutton = GtkSpinButton(adj=self.tb_margin_adjustment, digits=2)
self.lr_margin_spinbutton = GtkSpinButton(adj=self.lr_margin_adjustment, digits=2)
self.add_frame_option(_("GraphViz Options"), _("Top & Bottom Margins"), self.tb_margin_spinbutton)
self.add_frame_option(_("GraphViz Options"), _("Left & Right Margins"), self.lr_margin_spinbutton)
#------------------------------------------------------------------------
#
# Functions related to selecting/changing the current file format
@ -181,6 +230,13 @@ class GraphVizDialog(ReportDialog):
"""The style frame is not used in this dialog."""
pass
def parse_other_frames(self):
self.arrowhead_option = self.arrowhead_optionmenu.get_menu().get_active().get_data('i')
self.includedates = self.includedates_checkbutton.get_active()
self.includeurl = self.includeurl_checkbutton.get_active()
self.tb_margin = self.tb_margin_spinbutton.get_value_as_float()
self.lr_margin = self.lr_margin_spinbutton.get_value_as_float()
#------------------------------------------------------------------------
#
# Functions related to creating the actual report document.
@ -204,22 +260,20 @@ class GraphVizDialog(ReportDialog):
file.write("center=1;\n")
if self.pagecount == _scaled:
file.write("size=\"%3.1fin,%3.1fin\";\n" % (width-0.5,height-0.5))
file.write("ratio=compress;\n")
file.write("size=\"%3.1f,%3.1f\";\n" % (width-(self.lr_margin * 2),
height-(self.tb_margin * 2)))
else:
file.write("ratio=auto;\n")
if self.pagecount == _multiple:
file.write("page=\"%3.1f,%3.1f\";\n" % (width,height))
file.write("page=\"%3.1f,%3.1f\";\n" % (width,height))
if self.orien == PAPER_PORTRAIT:
file.write("orientation=portrait;\n")
else:
file.write("orientation=landscape;\n")
if self.orien == PAPER_LANDSCAPE:
file.write("rotate=90;\n")
if len(ind_list) > 1:
dump_index(ind_list,file)
dump_person(ind_list,file)
dump_index(ind_list,file,self.includedates,self.includeurl)
dump_person(ind_list,file,self.arrowhead_option)
file.write("}\n")
file.close()
@ -237,31 +291,44 @@ def report(database,person):
#
#
#------------------------------------------------------------------------
def dump_person(person_list,file):
def dump_person(person_list,file,arrowhead_option):
for person in person_list:
pid = string.replace(person.getId(),'-','_')
family = person.getMainParents()
if family == None:
continue
father = family.getFather()
if father and father in person_list:
file.write('p%s -> p%s;\n' % (person.getId(), father.getId()))
fid = string.replace(father.getId(),'-','_')
file.write('p%s -> p%s %s;\n' % (pid, fid, arrowhead_option))
mother = family.getMother()
if mother and mother in person_list:
file.write('p%s -> p%s;\n' % (person.getId(), mother.getId()))
mid = string.replace(mother.getId(),'-','_')
file.write('p%s -> p%s %s;\n' % (pid, mid, arrowhead_option))
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
def dump_index(person_list,file):
def dump_index(person_list,file,includedates,includeurl):
for person in person_list:
name = person.getPrimaryName().getName()
id = person.getId()
label = person.getPrimaryName().getName()
id = string.replace(person.getId(),'-','_')
if includedates:
if person.getBirth().getDateObj().getYearValid():
birth = '%i' % person.getBirth().getDateObj().getYear()
else:
birth = ''
if person.getDeath().getDateObj().getYearValid():
death = '%i' % person.getDeath().getDateObj().getYear()
else:
death = ''
label = label + '\\n(%s - %s)' % (birth, death)
file.write('p%s [shape=box, ' % id)
file.write('fontname="Arial", label="%s"];\n' % name)
if includeurl:
file.write('URL="%s.html", ' % id)
file.write('fontname="Arial", label="%s"];\n' % label)
#------------------------------------------------------------------------
#