2004-01-08 05:25:45 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-28 11:11:40 +05:30
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2007-04-23 17:16:26 +05:30
|
|
|
# Copyright (C) 2007 Brian G. Matherly
|
2004-01-08 05:25:45 +05:30
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2004-01-19 23:10:39 +05:30
|
|
|
# $Id$
|
|
|
|
|
2004-01-08 05:25:45 +05:30
|
|
|
"Graphical Reports/Ancestor Chart"
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import math
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import BaseDoc
|
|
|
|
from SubstKeywords import SubstKeywords
|
2007-11-29 20:32:40 +05:30
|
|
|
from PluginUtils import register_report, \
|
2007-12-31 11:51:58 +05:30
|
|
|
NumberOption, BooleanOption, TextOption, PersonOption
|
2007-11-29 20:32:40 +05:30
|
|
|
from ReportBase import Report, ReportUtils, CATEGORY_DRAW, MenuReportOptions,\
|
2007-11-29 05:03:40 +05:30
|
|
|
MODE_GUI, MODE_BKI, MODE_CLI
|
2007-06-28 11:11:40 +05:30
|
|
|
from BasicUtils import name_displayer
|
2006-03-10 01:51:32 +05:30
|
|
|
pt2cm = ReportUtils.pt2cm
|
|
|
|
cm2pt = ReportUtils.cm2pt
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2005-01-03 03:52:11 +05:30
|
|
|
# Constants
|
2004-01-08 05:25:45 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-01-03 03:52:11 +05:30
|
|
|
_BORN = _('b.')
|
|
|
|
_DIED = _('d.')
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-01-10 23:34:32 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2005-01-03 03:52:11 +05:30
|
|
|
# log2val
|
2004-01-10 23:34:32 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-01-03 03:52:11 +05:30
|
|
|
def log2(val):
|
|
|
|
return int(math.log10(val)/math.log10(2))
|
2004-01-10 23:34:32 +05:30
|
|
|
|
2004-01-08 05:25:45 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Layout class
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-01-03 03:52:11 +05:30
|
|
|
class GenChart:
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
def __init__(self,generations):
|
|
|
|
self.generations = generations
|
|
|
|
self.size = (2**(generations))
|
2007-02-19 08:19:35 +05:30
|
|
|
self.array = {}
|
2004-01-08 05:25:45 +05:30
|
|
|
self.map = {}
|
|
|
|
self.compress_map = {}
|
|
|
|
|
|
|
|
self.max_x = 0
|
2004-01-17 10:33:08 +05:30
|
|
|
self.ad = (self.size,generations)
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
def set(self,index,value):
|
|
|
|
x = log2(index)
|
|
|
|
y = index - (2**x)
|
|
|
|
delta = int((self.size/(2**(x))))
|
|
|
|
new_y = int((delta/2) + (y)*delta)
|
2007-02-19 08:19:35 +05:30
|
|
|
if not new_y in self.array:
|
|
|
|
self.array[new_y] = {}
|
2004-01-08 05:25:45 +05:30
|
|
|
self.array[new_y][x] = (value,index)
|
|
|
|
self.max_x = max(x,self.max_x)
|
|
|
|
self.map[value] = (new_y,x)
|
|
|
|
|
|
|
|
def index_to_xy(self,index):
|
|
|
|
if index:
|
|
|
|
x = log2(index)
|
|
|
|
ty = index - (2**x)
|
|
|
|
delta = int(self.size/(2**x))
|
|
|
|
y = int(delta/2 + ty*delta)
|
|
|
|
else:
|
|
|
|
x = 0
|
|
|
|
y = self.size/2
|
|
|
|
|
2004-01-10 23:34:32 +05:30
|
|
|
if len(self.compress_map) > 0:
|
2004-01-08 05:25:45 +05:30
|
|
|
return (x,self.compress_map[y])
|
|
|
|
else:
|
|
|
|
return (x,y)
|
|
|
|
|
|
|
|
def get(self,index):
|
2007-02-20 09:19:50 +05:30
|
|
|
(x,y) = self.index_to_xy(index)
|
|
|
|
return self.get_xy(x,y)
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
def get_xy(self,x,y):
|
2007-02-19 08:19:35 +05:30
|
|
|
value = 0
|
|
|
|
if y in self.array:
|
|
|
|
if x in self.array[y]:
|
|
|
|
value = self.array[y][x]
|
|
|
|
return value
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-01-18 10:39:00 +05:30
|
|
|
def set_xy(self,x,y,value):
|
2007-02-19 08:19:35 +05:30
|
|
|
if not y in self.array:
|
|
|
|
self.array[y] = {}
|
2004-01-18 10:39:00 +05:30
|
|
|
self.array[y][x] = value
|
|
|
|
|
2004-01-08 05:25:45 +05:30
|
|
|
def dimensions(self):
|
2007-02-20 09:19:50 +05:30
|
|
|
return (max(self.array.keys())+1,self.max_x+1)
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
def compress(self):
|
|
|
|
new_map = {}
|
2007-02-19 08:19:35 +05:30
|
|
|
new_array = {}
|
2004-01-08 05:25:45 +05:30
|
|
|
old_y = 0
|
|
|
|
new_y = 0
|
|
|
|
|
2007-02-19 08:19:35 +05:30
|
|
|
for key in self.array.keys():
|
|
|
|
i = self.array[key]
|
|
|
|
old_y = key
|
|
|
|
if self.not_blank(i.values()):
|
2004-01-08 05:25:45 +05:30
|
|
|
self.compress_map[old_y] = new_y
|
2007-02-19 08:19:35 +05:30
|
|
|
new_array[new_y] = i
|
2004-01-08 05:25:45 +05:30
|
|
|
x = 0
|
|
|
|
for entry in i:
|
2007-02-19 08:19:35 +05:30
|
|
|
new_map[entry] = (new_y,x)
|
2004-01-08 05:25:45 +05:30
|
|
|
x =+ 1
|
|
|
|
new_y += 1
|
|
|
|
self.array = new_array
|
|
|
|
self.map = new_map
|
2004-01-17 10:33:08 +05:30
|
|
|
self.ad = (new_y,self.ad[1])
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
def not_blank(self,line):
|
|
|
|
for i in line:
|
2005-01-03 03:52:11 +05:30
|
|
|
if i and type(i) == tuple:
|
2004-01-08 05:25:45 +05:30
|
|
|
return 1
|
|
|
|
return 0
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# AncestorChart
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2006-06-01 10:09:40 +05:30
|
|
|
class AncestorChart(Report):
|
2005-01-03 03:52:11 +05:30
|
|
|
|
|
|
|
def __init__(self,database,person,options_class):
|
|
|
|
"""
|
|
|
|
Creates AncestorChart object that produces the report.
|
|
|
|
|
|
|
|
The arguments are:
|
|
|
|
|
|
|
|
database - the GRAMPS database instance
|
|
|
|
person - currently selected person
|
|
|
|
options_class - instance of the Options class for this report
|
|
|
|
|
|
|
|
This report needs the following parameters (class variables)
|
|
|
|
that come in the options class.
|
|
|
|
|
|
|
|
gen - Maximum number of generations to include.
|
|
|
|
pagebbg - Whether to include page breaks between generations.
|
|
|
|
dispf - Display format for the output box.
|
|
|
|
singlep - Whether to scale to fit on a single page.
|
2007-02-20 09:19:50 +05:30
|
|
|
indblank - Whether to include blank pages.
|
2005-01-03 03:52:11 +05:30
|
|
|
compress - Whether to compress chart.
|
|
|
|
"""
|
2006-06-01 10:09:40 +05:30
|
|
|
Report.__init__(self,database,person,options_class)
|
2005-01-03 03:52:11 +05:30
|
|
|
|
|
|
|
self.display = options_class.handler.options_dict['dispf']
|
2007-03-03 08:42:04 +05:30
|
|
|
self.max_generations = options_class.handler.options_dict['maxgen']
|
2005-01-03 03:52:11 +05:30
|
|
|
self.force_fit = options_class.handler.options_dict['singlep']
|
2007-02-20 09:19:50 +05:30
|
|
|
self.incblank = options_class.handler.options_dict['incblank']
|
2005-01-03 03:52:11 +05:30
|
|
|
self.compress = options_class.handler.options_dict['compress']
|
2006-06-24 22:52:34 +05:30
|
|
|
|
2007-12-31 11:51:58 +05:30
|
|
|
pid = options_class.handler.options_dict['pid']
|
|
|
|
center_person = database.get_person_from_gramps_id(pid)
|
|
|
|
|
|
|
|
name = name_displayer.display_formal(center_person)
|
2006-06-24 22:52:34 +05:30
|
|
|
self.title = _("Ancestor Graph for %s") % name
|
2005-01-03 03:52:11 +05:30
|
|
|
|
2004-01-08 05:25:45 +05:30
|
|
|
self.map = {}
|
|
|
|
self.text = {}
|
2005-01-03 03:52:11 +05:30
|
|
|
|
2004-01-19 23:10:39 +05:30
|
|
|
self.box_width = 0
|
|
|
|
self.box_height = 0
|
2004-01-08 05:25:45 +05:30
|
|
|
self.lines = 0
|
2007-04-23 17:16:26 +05:30
|
|
|
self.scale = 1
|
2004-01-08 23:39:18 +05:30
|
|
|
|
2007-12-31 11:51:58 +05:30
|
|
|
self.apply_filter(center_person.get_handle(),1)
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
keys = self.map.keys()
|
|
|
|
keys.sort()
|
|
|
|
max_key = log2(keys[-1])
|
|
|
|
|
|
|
|
self.genchart = GenChart(max_key+1)
|
|
|
|
for key in self.map.keys():
|
|
|
|
self.genchart.set(key,self.map[key])
|
2004-05-05 07:34:30 +05:30
|
|
|
self.calc()
|
2007-04-23 17:16:26 +05:30
|
|
|
|
|
|
|
if self.force_fit:
|
|
|
|
self.scale_styles()
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2005-01-03 03:52:11 +05:30
|
|
|
def apply_filter(self,person_handle,index):
|
2004-01-08 05:25:45 +05:30
|
|
|
"""traverse the ancestors recursively until either the end
|
|
|
|
of a line is found, or until we reach the maximum number of
|
|
|
|
generations that we want to deal with"""
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
if (not person_handle) or (index >= 2**self.max_generations):
|
2004-01-08 05:25:45 +05:30
|
|
|
return
|
2004-07-28 07:59:07 +05:30
|
|
|
self.map[index] = person_handle
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
self.text[index] = []
|
2007-04-23 17:16:26 +05:30
|
|
|
|
|
|
|
style_sheet = self.doc.get_style_sheet()
|
|
|
|
pstyle = style_sheet.get_paragraph_style("AC2-Normal")
|
|
|
|
font = pstyle.get_font()
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2007-04-23 17:16:26 +05:30
|
|
|
em = self.doc.string_width(font,"m")
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
subst = SubstKeywords(self.database,person_handle)
|
2007-09-05 08:32:50 +05:30
|
|
|
self.text[index] = subst.replace_and_clean(self.display)
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
for line in self.text[index]:
|
2007-04-23 17:16:26 +05:30
|
|
|
this_box_width = self.doc.string_width(font,line)
|
2004-08-21 02:56:51 +05:30
|
|
|
self.box_width = max(self.box_width,this_box_width)
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
self.lines = max(self.lines,len(self.text[index]))
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-08-07 10:46:57 +05:30
|
|
|
person = self.database.get_person_from_handle(person_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
family_handle = person.get_main_parents_family_handle()
|
|
|
|
if family_handle:
|
2004-08-20 03:05:16 +05:30
|
|
|
family = self.database.get_family_from_handle(family_handle)
|
2005-01-03 03:52:11 +05:30
|
|
|
self.apply_filter(family.get_father_handle(),index*2)
|
|
|
|
self.apply_filter(family.get_mother_handle(),(index*2)+1)
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
def write_report(self):
|
|
|
|
|
2004-01-17 10:33:08 +05:30
|
|
|
(maxy,maxx) = self.genchart.dimensions()
|
|
|
|
maxh = int(self.uh/self.box_height)
|
|
|
|
|
2004-01-10 23:34:32 +05:30
|
|
|
if self.force_fit:
|
2004-01-18 04:09:00 +05:30
|
|
|
self.print_page(0,maxx,0,maxy,0,0)
|
2004-01-10 23:34:32 +05:30
|
|
|
else:
|
2004-01-17 10:33:08 +05:30
|
|
|
starty = 0
|
2004-01-18 04:09:00 +05:30
|
|
|
coly = 0
|
2007-02-26 04:34:03 +05:30
|
|
|
while starty < maxy:
|
2004-01-17 10:33:08 +05:30
|
|
|
startx = 0
|
2004-01-18 04:09:00 +05:30
|
|
|
colx = 0
|
2007-02-26 04:34:03 +05:30
|
|
|
while startx < maxx:
|
2004-01-17 10:33:08 +05:30
|
|
|
stopx = min(maxx,startx+self.generations_per_page)
|
|
|
|
stopy = min(maxy,starty+maxh)
|
2004-01-18 04:09:00 +05:30
|
|
|
self.print_page(startx,stopx,starty,stopy,colx,coly)
|
|
|
|
colx += 1
|
2004-01-17 10:33:08 +05:30
|
|
|
startx += self.generations_per_page
|
2004-01-18 04:09:00 +05:30
|
|
|
coly += 1
|
2004-01-18 10:39:00 +05:30
|
|
|
starty += maxh
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
def calc(self):
|
|
|
|
"""
|
|
|
|
calc - calculate the maximum width that a box needs to be. From
|
|
|
|
that and the page dimensions, calculate the proper place to put
|
|
|
|
the elements on a page.
|
|
|
|
"""
|
2007-04-23 17:16:26 +05:30
|
|
|
style_sheet = self.doc.get_style_sheet()
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-01-18 10:39:00 +05:30
|
|
|
self.add_lines()
|
|
|
|
if self.compress:
|
|
|
|
self.genchart.compress()
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-01-10 23:34:32 +05:30
|
|
|
self.box_pad_pts = 10
|
2004-01-17 10:33:08 +05:30
|
|
|
if self.title and self.force_fit:
|
2007-04-23 17:16:26 +05:30
|
|
|
pstyle = style_sheet.get_paragraph_style("AC2-Title")
|
|
|
|
tfont = pstyle.get_font()
|
2007-10-01 14:35:40 +05:30
|
|
|
self.offset = pt2cm(1.25 * tfont.get_size())
|
|
|
|
|
|
|
|
gstyle = style_sheet.get_draw_style("AC2-box")
|
|
|
|
shadow_height = gstyle.get_shadow_space()
|
2004-01-10 23:34:32 +05:30
|
|
|
else:
|
2008-01-09 10:43:27 +05:30
|
|
|
# Make space for the page number labels at the bottom.
|
|
|
|
p = style_sheet.get_paragraph_style("AC2-Normal")
|
|
|
|
font = p.get_font()
|
|
|
|
lheight = pt2cm(1.2*font.get_size())
|
|
|
|
lwidth = pt2cm(1.1*self.doc.string_width(font,"(00,00)"))
|
|
|
|
self.page_label_x_offset = self.doc.get_usable_width() - lwidth
|
|
|
|
self.page_label_y_offset = self.doc.get_usable_height() - lheight
|
|
|
|
|
|
|
|
self.offset = pt2cm(1.25 * font.get_size())
|
2007-10-01 14:35:40 +05:30
|
|
|
shadow_height = 0
|
|
|
|
self.uh = self.doc.get_usable_height() - self.offset - shadow_height
|
|
|
|
uw = self.doc.get_usable_width() - pt2cm(self.box_pad_pts)
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
calc_width = pt2cm(self.box_width + self.box_pad_pts) + 0.2
|
|
|
|
self.box_width = pt2cm(self.box_width)
|
2007-04-23 17:16:26 +05:30
|
|
|
pstyle = style_sheet.get_paragraph_style("AC2-Normal")
|
|
|
|
font = pstyle.get_font()
|
|
|
|
self.box_height = self.lines*pt2cm(1.25*font.get_size())
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-01-10 23:34:32 +05:30
|
|
|
if self.force_fit:
|
2004-01-08 23:39:18 +05:30
|
|
|
(maxy,maxx) = self.genchart.dimensions()
|
|
|
|
|
2004-01-10 23:34:32 +05:30
|
|
|
bw = calc_width/(uw/maxx)
|
2004-01-17 10:33:08 +05:30
|
|
|
bh = self.box_height/(self.uh/maxy)
|
2004-01-08 23:39:18 +05:30
|
|
|
|
|
|
|
self.scale = max(bw,bh)
|
|
|
|
self.box_width = self.box_width/self.scale
|
2004-01-10 23:34:32 +05:30
|
|
|
self.box_height = self.box_height/self.scale
|
|
|
|
self.box_pad_pts = self.box_pad_pts/self.scale
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-01-17 10:33:08 +05:30
|
|
|
maxh = int(self.uh/self.box_height)
|
2004-01-10 23:34:32 +05:30
|
|
|
maxw = int(uw/calc_width)
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
if log2(maxh) < maxw:
|
|
|
|
self.generations_per_page = int(log2(maxh))
|
|
|
|
else:
|
2004-01-17 10:33:08 +05:30
|
|
|
self.generations_per_page = maxw
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
# build array of x indices
|
|
|
|
|
2004-01-10 23:34:32 +05:30
|
|
|
self.delta = pt2cm(self.box_pad_pts) + self.box_width + 0.2
|
2004-01-17 10:33:08 +05:30
|
|
|
if not self.force_fit:
|
|
|
|
calc_width = self.box_width + 0.2 + pt2cm(self.box_pad_pts)
|
|
|
|
remain = self.doc.get_usable_width() - ((self.generations_per_page)*calc_width)
|
|
|
|
self.delta += remain/(self.generations_per_page)
|
2007-04-23 17:16:26 +05:30
|
|
|
|
|
|
|
def scale_styles(self):
|
|
|
|
"""
|
|
|
|
Scale the styles for this report. This must be done in the constructor.
|
|
|
|
"""
|
|
|
|
style_sheet = self.doc.get_style_sheet()
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2007-04-23 17:16:26 +05:30
|
|
|
g = style_sheet.get_draw_style("AC2-box")
|
|
|
|
g.set_shadow(g.get_shadow(),g.get_shadow_space()/self.scale)
|
|
|
|
g.set_line_width(g.get_line_width()/self.scale)
|
|
|
|
style_sheet.add_draw_style("AC2-box",g)
|
|
|
|
|
|
|
|
p = style_sheet.get_paragraph_style("AC2-Normal")
|
|
|
|
font = p.get_font()
|
|
|
|
font.set_size(font.get_size()/self.scale)
|
|
|
|
p.set_font(font)
|
|
|
|
style_sheet.add_paragraph_style("AC2-Normal",p)
|
|
|
|
|
|
|
|
self.doc.set_style_sheet(style_sheet)
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-01-18 04:09:00 +05:30
|
|
|
def print_page(self,startx,stopx,starty,stopy,colx,coly):
|
2007-02-20 09:19:50 +05:30
|
|
|
|
|
|
|
if not self.incblank:
|
|
|
|
blank = True
|
|
|
|
for y in range(starty,stopy):
|
|
|
|
for x in range(startx,stopx):
|
|
|
|
if self.genchart.get_xy(x,y) != 0:
|
|
|
|
blank = False
|
|
|
|
break
|
|
|
|
if not blank: break
|
|
|
|
if blank: return
|
2004-01-17 10:33:08 +05:30
|
|
|
|
2004-01-08 05:25:45 +05:30
|
|
|
self.doc.start_page()
|
2004-01-17 10:33:08 +05:30
|
|
|
if self.title and self.force_fit:
|
2004-03-10 07:54:11 +05:30
|
|
|
self.doc.center_text('AC2-title',self.title,self.doc.get_usable_width()/2,0)
|
2004-01-17 10:33:08 +05:30
|
|
|
phys_y = 0
|
|
|
|
for y in range(starty,stopy):
|
|
|
|
phys_x = 0
|
|
|
|
for x in range(startx,stopx):
|
2004-01-08 05:25:45 +05:30
|
|
|
value = self.genchart.get_xy(x,y)
|
|
|
|
if value:
|
2005-01-03 03:52:11 +05:30
|
|
|
if type(value) == tuple:
|
2004-01-18 10:39:00 +05:30
|
|
|
(person,index) = value
|
2005-01-03 03:52:11 +05:30
|
|
|
text = '\n'.join(self.text[index])
|
2007-02-26 03:23:38 +05:30
|
|
|
self.doc.draw_box("AC2-box",
|
|
|
|
text,
|
|
|
|
phys_x*self.delta,
|
|
|
|
phys_y*self.box_height+self.offset,
|
|
|
|
self.box_width,
|
|
|
|
self.box_height )
|
2004-01-18 10:39:00 +05:30
|
|
|
elif value == 2:
|
2004-03-10 07:54:11 +05:30
|
|
|
self.doc.draw_line("AC2-line",
|
2004-01-18 10:39:00 +05:30
|
|
|
phys_x*self.delta+self.box_width*0.5,
|
|
|
|
phys_y*self.box_height+self.offset,
|
|
|
|
phys_x*self.delta+self.box_width*0.5,
|
|
|
|
(phys_y+1)*self.box_height+self.offset)
|
|
|
|
elif value == 1:
|
|
|
|
x1 = phys_x*self.delta+self.box_width*0.5
|
|
|
|
x2 = (phys_x+1)*self.delta
|
|
|
|
y1 = phys_y*self.box_height+self.offset+self.box_height/2
|
|
|
|
y2 = (phys_y+1)*self.box_height+self.offset
|
2004-03-10 07:54:11 +05:30
|
|
|
self.doc.draw_line("AC2-line",x1,y1,x1,y2)
|
|
|
|
self.doc.draw_line("AC2-line",x1,y1,x2,y1)
|
2004-01-18 10:39:00 +05:30
|
|
|
elif value == 3:
|
|
|
|
x1 = phys_x*self.delta+self.box_width*0.5
|
|
|
|
x2 = (phys_x+1)*self.delta
|
|
|
|
y1 = (phys_y)*self.box_height+self.offset+self.box_height/2
|
|
|
|
y2 = (phys_y)*self.box_height+self.offset
|
2004-03-10 07:54:11 +05:30
|
|
|
self.doc.draw_line("AC2-line",x1,y1,x1,y2)
|
|
|
|
self.doc.draw_line("AC2-line",x1,y1,x2,y1)
|
2004-01-18 10:39:00 +05:30
|
|
|
|
2004-01-17 10:33:08 +05:30
|
|
|
phys_x +=1
|
|
|
|
phys_y += 1
|
2004-01-08 05:25:45 +05:30
|
|
|
|
2004-01-18 04:09:00 +05:30
|
|
|
if not self.force_fit:
|
2004-03-10 07:54:11 +05:30
|
|
|
self.doc.draw_text('AC2-box',
|
2004-01-20 01:36:14 +05:30
|
|
|
'(%d,%d)' % (colx+1,coly+1),
|
2008-01-09 10:43:27 +05:30
|
|
|
self.page_label_x_offset,
|
|
|
|
self.page_label_y_offset)
|
2004-01-08 05:25:45 +05:30
|
|
|
self.doc.end_page()
|
|
|
|
|
2004-01-18 10:39:00 +05:30
|
|
|
def add_lines(self):
|
|
|
|
|
|
|
|
(my,mx) = self.genchart.dimensions()
|
|
|
|
|
|
|
|
for y in range(0,my):
|
|
|
|
for x in range(0,mx):
|
|
|
|
value = self.genchart.get_xy(x,y)
|
|
|
|
if not value:
|
|
|
|
continue
|
2005-01-03 03:52:11 +05:30
|
|
|
if type(value) == tuple:
|
2004-01-18 10:39:00 +05:30
|
|
|
(person,index) = value
|
|
|
|
if self.genchart.get(index*2):
|
|
|
|
(px,py) = self.genchart.index_to_xy(index*2)
|
|
|
|
self.genchart.set_xy(x,py,1)
|
|
|
|
for ty in range(py+1,y):
|
|
|
|
self.genchart.set_xy(x,ty,2)
|
|
|
|
if self.genchart.get(index*2+1):
|
|
|
|
(px,py) = self.genchart.index_to_xy(index*2+1)
|
|
|
|
self.genchart.set_xy(px-1,py,3)
|
|
|
|
for ty in range(y+1,py):
|
|
|
|
self.genchart.set_xy(x,ty,2)
|
2007-02-20 09:19:50 +05:30
|
|
|
|
2004-01-08 05:25:45 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2007-11-29 05:03:40 +05:30
|
|
|
class AncestorChartOptions(MenuReportOptions):
|
2005-01-03 03:52:11 +05:30
|
|
|
|
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
|
|
|
|
2007-12-30 11:11:16 +05:30
|
|
|
def __init__(self,name,dbstate=None):
|
|
|
|
MenuReportOptions.__init__(self,name,dbstate)
|
2007-03-03 08:42:04 +05:30
|
|
|
|
2007-12-30 11:11:16 +05:30
|
|
|
def add_menu_options(self,menu,dbstate):
|
2007-12-31 11:51:58 +05:30
|
|
|
|
|
|
|
id = ""
|
|
|
|
if dbstate:
|
|
|
|
id = dbstate.get_active_person().get_gramps_id()
|
|
|
|
pid = PersonOption(_("Center Person"),id,dbstate)
|
2008-01-01 03:12:58 +05:30
|
|
|
pid.set_help(_("The center person for the report"))
|
2007-12-31 11:51:58 +05:30
|
|
|
menu.add_option("","pid",pid)
|
|
|
|
|
2007-09-05 08:32:50 +05:30
|
|
|
category_name = _("Report Options")
|
|
|
|
|
2007-09-10 17:47:42 +05:30
|
|
|
max_gen = NumberOption(_("Generations"),10,1,15)
|
2007-09-05 08:32:50 +05:30
|
|
|
max_gen.set_help(_("The number of generations to include in the report"))
|
|
|
|
menu.add_option(category_name,"maxgen",max_gen)
|
|
|
|
|
|
|
|
disp = TextOption(_("Display Format"),
|
|
|
|
["$n","%s $b" % _BORN,"%s $d" %_DIED] )
|
|
|
|
disp.set_help(_("Display format for the outputbox."))
|
|
|
|
menu.add_option(category_name,"dispf",disp)
|
|
|
|
|
|
|
|
scale = BooleanOption(_('Sc_ale to fit on a single page'),True)
|
|
|
|
scale.set_help(_("Whether to scale to fit on a single page."))
|
|
|
|
menu.add_option(category_name,"singlep",scale)
|
|
|
|
|
|
|
|
blank = BooleanOption(_('Include Blank Pages'),True)
|
|
|
|
blank.set_help(_("Whether to include pages that are blank."))
|
|
|
|
menu.add_option(category_name,"incblank",blank)
|
|
|
|
|
|
|
|
compress = BooleanOption(_('Co_mpress chart'),True)
|
|
|
|
compress.set_help(_("Whether to compress chart."))
|
|
|
|
menu.add_option(category_name,"compress",compress)
|
2005-01-03 03:52:11 +05:30
|
|
|
|
|
|
|
def make_default_style(self,default_style):
|
|
|
|
"""Make the default output style for the Ancestor Chart report."""
|
2007-04-23 17:16:26 +05:30
|
|
|
|
|
|
|
## Paragraph Styles:
|
2005-01-03 03:52:11 +05:30
|
|
|
f = BaseDoc.FontStyle()
|
|
|
|
f.set_size(9)
|
|
|
|
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
|
|
|
p.set_font(f)
|
|
|
|
p.set_description(_('The basic style used for the text display.'))
|
2007-04-23 17:16:26 +05:30
|
|
|
default_style.add_paragraph_style("AC2-Normal",p)
|
2005-01-03 03:52:11 +05:30
|
|
|
|
|
|
|
f = BaseDoc.FontStyle()
|
|
|
|
f.set_size(16)
|
|
|
|
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
|
|
|
p.set_font(f)
|
|
|
|
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
|
|
|
p.set_description(_('The basic style used for the title display.'))
|
2007-04-23 17:16:26 +05:30
|
|
|
default_style.add_paragraph_style("AC2-Title",p)
|
|
|
|
|
|
|
|
## Draw styles
|
|
|
|
g = BaseDoc.GraphicsStyle()
|
|
|
|
g.set_paragraph_style("AC2-Normal")
|
|
|
|
g.set_shadow(1,0.2)
|
|
|
|
g.set_fill_color((255,255,255))
|
|
|
|
default_style.add_draw_style("AC2-box",g)
|
|
|
|
|
|
|
|
g = BaseDoc.GraphicsStyle()
|
|
|
|
g.set_paragraph_style("AC2-Title")
|
|
|
|
g.set_color((0,0,0))
|
|
|
|
g.set_fill_color((255,255,255))
|
|
|
|
g.set_line_width(0)
|
|
|
|
default_style.add_draw_style("AC2-title",g)
|
|
|
|
|
|
|
|
g = BaseDoc.GraphicsStyle()
|
|
|
|
default_style.add_draw_style("AC2-line",g)
|
2004-01-08 05:25:45 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
register_report(
|
2007-08-28 17:35:02 +05:30
|
|
|
name = 'ancestor_chart',
|
2006-06-01 10:09:40 +05:30
|
|
|
category = CATEGORY_DRAW,
|
2005-01-03 03:52:11 +05:30
|
|
|
report_class = AncestorChart,
|
|
|
|
options_class = AncestorChartOptions,
|
2006-06-01 10:09:40 +05:30
|
|
|
modes = MODE_GUI | MODE_BKI | MODE_CLI,
|
2005-12-06 12:08:09 +05:30
|
|
|
translated_name = _("Ancestor Graph"),
|
|
|
|
status = _("Stable"),
|
2005-01-03 03:52:11 +05:30
|
|
|
author_name = "Donald N. Allingham",
|
2005-12-06 12:08:09 +05:30
|
|
|
author_email = "don@gramps-project.org",
|
2005-01-03 03:52:11 +05:30
|
|
|
description = _("Produces a graphical ancestral tree graph"),
|
2004-01-08 05:25:45 +05:30
|
|
|
)
|