2005-12-06 12:08:09 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-28 11:11:40 +05:30
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2008-01-06 02:12:05 +05:30
|
|
|
# Copyright (C) 2007-2008 Brian G. Matherly
|
2009-01-20 14:40:01 +05:30
|
|
|
# Copyright (C) 2009 Craig J. Anderson
|
2005-12-06 12:08:09 +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
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
2008-03-02 04:17:48 +05:30
|
|
|
"""Reports/Graphical Reports/Descendant Tree"""
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2007-09-05 08:32:50 +05:30
|
|
|
from BasicUtils import name_displayer
|
2008-10-02 09:32:10 +05:30
|
|
|
from gen.plug import PluginManager
|
2008-09-27 19:26:17 +05:30
|
|
|
from gen.plug.menu import TextOption, NumberOption, BooleanOption, PersonOption
|
2008-10-02 09:32:10 +05:30
|
|
|
from ReportBase import Report, MenuReportOptions, ReportUtils, CATEGORY_DRAW
|
2007-09-05 08:32:50 +05:30
|
|
|
from SubstKeywords import SubstKeywords
|
2008-11-08 21:05:20 +05:30
|
|
|
from TransUtils import sgettext as _
|
2007-09-05 08:32:50 +05:30
|
|
|
import BaseDoc
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2006-03-10 02:19:29 +05:30
|
|
|
pt2cm = ReportUtils.pt2cm
|
|
|
|
cm2pt = ReportUtils.cm2pt
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2008-11-08 21:05:20 +05:30
|
|
|
_BORN = _('short for born|b.')
|
2009-01-20 14:40:01 +05:30
|
|
|
_MARR = _('short for married|m.')
|
2008-11-08 21:05:20 +05:30
|
|
|
_DIED = _('short for died|d.')
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
_LINE_HORIZONTAL = 1
|
|
|
|
_LINE_VERTICAL = 2
|
|
|
|
_LINE_ANGLE = 3
|
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
_PERSON_DIRECT = 1
|
|
|
|
_PERSON_SPOUSE = 2
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Layout class
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class GenChart:
|
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
def __init__(self, generations):
|
2005-12-06 12:08:09 +05:30
|
|
|
self.generations = generations
|
|
|
|
self.map = {}
|
|
|
|
|
|
|
|
self.array = {}
|
2009-01-20 14:40:01 +05:30
|
|
|
self.sparray = {}
|
2005-12-06 12:08:09 +05:30
|
|
|
self.max_x = 0
|
|
|
|
self.max_y = 0
|
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
def get_xy(self, x, y):
|
2008-07-17 23:40:32 +05:30
|
|
|
if y not in self.array:
|
2005-12-06 12:08:09 +05:30
|
|
|
return 0
|
|
|
|
return self.array[y].get(x,0)
|
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
def set_xy(self, x, y, value):
|
2005-12-06 12:08:09 +05:30
|
|
|
self.max_x = max(self.max_x,x)
|
|
|
|
self.max_y = max(self.max_y,y)
|
|
|
|
|
2008-07-17 23:40:32 +05:30
|
|
|
if y not in self.array:
|
2005-12-06 12:08:09 +05:30
|
|
|
self.array[y] = {}
|
|
|
|
self.array[y][x] = value
|
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
def get_sp(self, col_x, row_y):
|
|
|
|
"""gets whether person at x,y
|
|
|
|
is a direct descendent or a spouse"""
|
|
|
|
if (col_x, row_y) not in self.sparray:
|
|
|
|
return None
|
|
|
|
return self.sparray[col_x, row_y]
|
|
|
|
|
|
|
|
def set_sp(self, col_x, row_y, value):
|
|
|
|
"""sets whether person at x,y
|
|
|
|
is a direct descendent or a spouse"""
|
|
|
|
self.sparray[col_x, row_y] = value
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
def dimensions(self):
|
2009-01-20 14:40:01 +05:30
|
|
|
return (self.max_y+1, self.max_x+1)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
def not_blank(self, line):
|
2005-12-06 12:08:09 +05:30
|
|
|
for i in line:
|
2008-05-26 01:25:47 +05:30
|
|
|
if i and isinstance(i, tuple):
|
2005-12-06 12:08:09 +05:30
|
|
|
return 1
|
|
|
|
return 0
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2008-03-02 04:17:48 +05:30
|
|
|
# DescendTree
|
2005-12-06 12:08:09 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2008-03-02 04:17:48 +05:30
|
|
|
class DescendTree(Report):
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-02-20 10:22:10 +05:30
|
|
|
def __init__(self, database, options_class):
|
2005-12-06 12:08:09 +05:30
|
|
|
"""
|
2008-03-02 04:17:48 +05:30
|
|
|
Create DescendTree object that produces the report.
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
dispf - Display format for the output box.
|
|
|
|
singlep - Whether to scale to fit on a single page.
|
|
|
|
maxgen - Maximum number of generations to include.
|
|
|
|
"""
|
2008-02-20 10:22:10 +05:30
|
|
|
Report.__init__(self, database, options_class)
|
2008-01-23 11:11:46 +05:30
|
|
|
|
|
|
|
menu = options_class.menu
|
|
|
|
self.display = menu.get_option_by_name('dispf').get_value()
|
|
|
|
self.max_generations = menu.get_option_by_name('maxgen').get_value()
|
|
|
|
self.force_fit = menu.get_option_by_name('singlep').get_value()
|
|
|
|
self.incblank = menu.get_option_by_name('incblank').get_value()
|
|
|
|
pid = menu.get_option_by_name('pid').get_value()
|
2008-01-06 02:12:05 +05:30
|
|
|
center_person = database.get_person_from_gramps_id(pid)
|
2006-06-24 22:52:34 +05:30
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
self.showspouse = menu.get_option_by_name('shows').get_value()
|
|
|
|
|
2008-01-06 02:12:05 +05:30
|
|
|
name = name_displayer.display_formal(center_person)
|
2006-06-24 22:52:34 +05:30
|
|
|
self.title = _("Descendant Chart for %s") % name
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
self.map = {}
|
|
|
|
self.text = {}
|
|
|
|
|
|
|
|
self.box_width = 0
|
|
|
|
self.box_height = 0
|
|
|
|
self.lines = 0
|
2007-04-23 17:16:26 +05:30
|
|
|
self.scale = 1
|
2005-12-06 12:08:09 +05:30
|
|
|
self.box_gap = 0.2
|
|
|
|
|
|
|
|
self.genchart = GenChart(32)
|
|
|
|
|
2008-01-06 02:12:05 +05:30
|
|
|
self.apply_filter(center_person.get_handle(),0,0)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
self.calc()
|
2007-04-23 17:16:26 +05:30
|
|
|
|
|
|
|
if self.force_fit:
|
|
|
|
self.scale_styles()
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
def add_person(self, person_handle, col_x, row_y, spouse_level):
|
|
|
|
"""Add a new person into the x,y position
|
|
|
|
also sets wether the person is:
|
|
|
|
- a direct descendent or a spouse
|
|
|
|
- the max length of the text/box, and number of lines"""
|
|
|
|
self.genchart.set_xy(col_x, row_y, person_handle)
|
|
|
|
self.genchart.set_sp(col_x, row_y, spouse_level)
|
2007-04-23 17:16:26 +05:30
|
|
|
|
|
|
|
style_sheet = self.doc.get_style_sheet()
|
|
|
|
pstyle = style_sheet.get_paragraph_style("DC2-Normal")
|
|
|
|
font = pstyle.get_font()
|
2005-12-06 12:08:09 +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
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
subst = SubstKeywords(self.database, person_handle)
|
|
|
|
self.text[(col_x, row_y)] = subst.replace_and_clean(self.display)
|
|
|
|
for line in self.text[(col_x, row_y)]:
|
|
|
|
this_box_width = self.doc.string_width(font, line) + 2*em
|
|
|
|
self.box_width = max(self.box_width, this_box_width)
|
|
|
|
|
|
|
|
self.lines = max(self.lines, len(self.text[(col_x, row_y)]))
|
|
|
|
|
|
|
|
def apply_filter(self, person_handle, col_x, row_y):
|
|
|
|
"""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"""
|
|
|
|
|
|
|
|
if col_x/2 >= self.max_generations:
|
|
|
|
return 0
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
person = self.database.get_person_from_handle(person_handle)
|
|
|
|
self.add_person(person_handle, col_x, row_y, _PERSON_DIRECT)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
working_col = 1
|
|
|
|
next_col = 0
|
2005-12-06 12:08:09 +05:30
|
|
|
for family_handle in person.get_family_handle_list():
|
|
|
|
|
|
|
|
family = self.database.get_family_from_handle(family_handle)
|
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
if self.showspouse:
|
|
|
|
spouse_handle = ReportUtils.find_spouse(person, family)
|
|
|
|
self.add_person(spouse_handle, col_x, row_y+working_col,
|
|
|
|
_PERSON_SPOUSE)
|
|
|
|
working_col += 1
|
|
|
|
|
2006-04-22 12:26:48 +05:30
|
|
|
for child_ref in family.get_child_ref_list():
|
2009-01-20 14:40:01 +05:30
|
|
|
next_col += self.apply_filter(child_ref.ref, col_x+2,
|
|
|
|
row_y+next_col)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
working_col = next_col = max(working_col, next_col)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
return working_col
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
def add_lines(self):
|
|
|
|
(maxy, maxx) = self.genchart.dimensions()
|
|
|
|
|
|
|
|
for y in range(0, maxy+1):
|
|
|
|
for x in range(0, maxx+1):
|
2005-12-06 12:08:09 +05:30
|
|
|
# skip columns reserved for rows - no data here
|
|
|
|
if x%2:
|
|
|
|
continue
|
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
# if we have a direct child to the right of a person
|
|
|
|
# check to see if the child is a descendant of the person
|
|
|
|
if self.genchart.get_sp(x+2, y) == _PERSON_DIRECT:
|
|
|
|
if self.genchart.get_sp(x, y) == _PERSON_DIRECT:
|
|
|
|
self.genchart.set_xy(x+1, y , _LINE_HORIZONTAL)
|
|
|
|
continue
|
|
|
|
elif self.genchart.get_sp(x, y) == _PERSON_SPOUSE and \
|
|
|
|
self.genchart.get_sp(x, y-1) != _PERSON_DIRECT:
|
|
|
|
self.genchart.set_xy(x+1, y , _LINE_HORIZONTAL)
|
|
|
|
continue
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
|
|
|
continue
|
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
self.genchart.set_xy(x+1, y, _LINE_ANGLE)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
# look through the entries ABOVE this one. All direct people
|
|
|
|
# in the next column are descendants until we hit the first
|
|
|
|
# direct person (marked with _LINE_HORIZONTAL)
|
|
|
|
last = y-1
|
|
|
|
while last > 0:
|
|
|
|
if self.genchart.get_xy(x+1, last) == 0:
|
|
|
|
self.genchart.set_xy(x+1, last, _LINE_VERTICAL)
|
|
|
|
else:
|
2005-12-06 12:08:09 +05:30
|
|
|
break
|
2009-01-20 14:40:01 +05:30
|
|
|
last -= 1
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
|
|
|
|
def write_report(self):
|
|
|
|
|
|
|
|
(maxy,maxx) = self.genchart.dimensions()
|
|
|
|
maxx = (maxx-1)*2
|
|
|
|
maxh = int((self.uh-0.75)/(self.box_height*1.25))
|
|
|
|
|
|
|
|
if self.force_fit:
|
2009-01-20 14:40:01 +05:30
|
|
|
self.print_page(0, maxx, 0, maxy, 0, 0)
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
|
|
|
starty = 0
|
|
|
|
coly = 0
|
|
|
|
while starty < maxy:
|
|
|
|
startx = 0
|
|
|
|
colx = 0
|
|
|
|
while startx < maxx:
|
2009-01-20 14:40:01 +05:30
|
|
|
stopx = min(maxx, startx+self.generations_per_page*2)
|
|
|
|
stopy = min(maxy, starty+maxh)
|
|
|
|
self.print_page(startx, stopx, starty, stopy, colx, coly)
|
2005-12-06 12:08:09 +05:30
|
|
|
colx += 1
|
|
|
|
startx += self.generations_per_page*2
|
|
|
|
coly += 1
|
|
|
|
starty += maxh
|
|
|
|
|
|
|
|
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()
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
self.add_lines()
|
|
|
|
|
|
|
|
self.box_pad_pts = 10
|
|
|
|
if self.title and self.force_fit:
|
2007-04-23 17:16:26 +05:30
|
|
|
pstyle = style_sheet.get_paragraph_style("DC2-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("DC2-box")
|
|
|
|
shadow_height = gstyle.get_shadow_space()
|
2005-12-06 12:08:09 +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("DC2-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)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
calc_width = pt2cm(self.box_width + self.box_pad_pts) + self.box_gap
|
|
|
|
self.box_width = pt2cm(self.box_width)
|
2007-04-23 17:16:26 +05:30
|
|
|
pstyle = style_sheet.get_paragraph_style("DC2-Normal")
|
|
|
|
font = pstyle.get_font()
|
|
|
|
self.box_height = self.lines*pt2cm(1.25*font.get_size())
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
self.scale = 1
|
|
|
|
|
|
|
|
if self.force_fit:
|
2009-01-20 14:40:01 +05:30
|
|
|
(maxy, maxx) = self.genchart.dimensions()
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
bw = (calc_width/(uw/(maxx+1)))
|
|
|
|
bh = (self.box_height*(1.25)+self.box_gap)/(self.uh/maxy)
|
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
self.scale = max(bw/2, bh)
|
2005-12-06 12:08:09 +05:30
|
|
|
self.box_width = self.box_width/self.scale
|
|
|
|
self.box_height = self.box_height/self.scale
|
|
|
|
self.box_pad_pts = self.box_pad_pts/self.scale
|
|
|
|
self.box_gap = self.box_gap/self.scale
|
|
|
|
|
2008-01-11 12:20:46 +05:30
|
|
|
# maxh = int((self.uh)/(self.box_height+self.box_gap))
|
2005-12-06 12:08:09 +05:30
|
|
|
maxw = int(uw/calc_width)
|
|
|
|
|
|
|
|
# build array of x indices
|
|
|
|
|
|
|
|
self.generations_per_page = maxw
|
|
|
|
|
|
|
|
self.delta = pt2cm(self.box_pad_pts) + self.box_width + self.box_gap
|
|
|
|
if not self.force_fit:
|
|
|
|
calc_width = self.box_width + pt2cm(self.box_pad_pts)
|
2009-01-20 14:40:01 +05:30
|
|
|
remain = self.doc.get_usable_width() - \
|
|
|
|
((self.generations_per_page)*calc_width)
|
2005-12-06 12:08:09 +05:30
|
|
|
self.delta += remain/float(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()
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2007-04-23 17:16:26 +05:30
|
|
|
g = style_sheet.get_draw_style("DC2-box")
|
|
|
|
g.set_shadow(g.get_shadow(),g.get_shadow_space()/self.scale)
|
2005-12-06 12:08:09 +05:30
|
|
|
g.set_line_width(g.get_line_width()/self.scale)
|
2007-04-23 17:16:26 +05:30
|
|
|
style_sheet.add_draw_style("DC2-box",g)
|
|
|
|
|
|
|
|
p = style_sheet.get_paragraph_style("DC2-Normal")
|
|
|
|
font = p.get_font()
|
|
|
|
font.set_size(font.get_size()/self.scale)
|
|
|
|
p.set_font(font)
|
2009-01-20 14:40:01 +05:30
|
|
|
style_sheet.add_paragraph_style("DC2-Normal", p)
|
2007-04-23 17:16:26 +05:30
|
|
|
|
|
|
|
self.doc.set_style_sheet(style_sheet)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2009-01-20 14:40:01 +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
|
2009-01-20 14:40:01 +05:30
|
|
|
for y in range(starty, stopy):
|
|
|
|
for x in range(startx, stopx):
|
|
|
|
if self.genchart.get_xy(x, y) != 0:
|
2007-02-20 09:19:50 +05:30
|
|
|
blank = False
|
|
|
|
break
|
|
|
|
if not blank: break
|
|
|
|
if blank: return
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
self.doc.start_page()
|
|
|
|
if self.title and self.force_fit:
|
2009-01-20 14:40:01 +05:30
|
|
|
self.doc.center_text('DC2-title', self.title,
|
|
|
|
self.doc.get_usable_width()/2,0)
|
2005-12-06 12:08:09 +05:30
|
|
|
phys_y = 1
|
|
|
|
bh = self.box_height * 1.25
|
2009-01-20 14:40:01 +05:30
|
|
|
for y in range(starty, stopy):
|
2005-12-06 12:08:09 +05:30
|
|
|
phys_x = 0
|
2009-01-20 14:40:01 +05:30
|
|
|
for x in range(startx, stopx):
|
|
|
|
value = self.genchart.get_xy(x, y)
|
2008-05-26 01:25:47 +05:30
|
|
|
if isinstance(value, basestring):
|
2009-01-20 14:40:01 +05:30
|
|
|
text = '\n'.join(self.text[(x, y)])
|
2005-12-06 12:08:09 +05:30
|
|
|
xbegin = phys_x*self.delta
|
|
|
|
yend = phys_y*bh+self.offset
|
2007-02-26 03:23:38 +05:30
|
|
|
self.doc.draw_box("DC2-box",
|
|
|
|
text,
|
|
|
|
xbegin,
|
|
|
|
yend,
|
|
|
|
self.box_width,
|
|
|
|
self.box_height)
|
2005-12-06 12:08:09 +05:30
|
|
|
elif value == _LINE_HORIZONTAL:
|
|
|
|
xbegin = phys_x*self.delta
|
|
|
|
ystart = (phys_y*bh + self.box_height/2.0) + self.offset
|
|
|
|
xstart = xbegin + self.box_width
|
|
|
|
xstop = (phys_x+1)*self.delta
|
2009-01-20 14:40:01 +05:30
|
|
|
self.doc.draw_line('DC2-line', xstart, ystart, xstop,
|
|
|
|
ystart)
|
2005-12-06 12:08:09 +05:30
|
|
|
elif value == _LINE_VERTICAL:
|
|
|
|
ystart = ((phys_y-1)*bh + self.box_height/2.0) + self.offset
|
|
|
|
ystop = (phys_y*bh + self.box_height/2.0) + self.offset
|
|
|
|
xlast = (phys_x*self.delta) + self.box_width + self.box_gap
|
|
|
|
self.doc.draw_line('DC2-line', xlast, ystart, xlast, ystop)
|
|
|
|
elif value == _LINE_ANGLE:
|
|
|
|
ystart = ((phys_y-1)*bh + self.box_height/2.0) + self.offset
|
|
|
|
ystop = (phys_y*bh + self.box_height/2.0) + self.offset
|
|
|
|
xlast = (phys_x*self.delta) + self.box_width + self.box_gap
|
|
|
|
xnext = (phys_x+1)*self.delta
|
|
|
|
self.doc.draw_line('DC2-line', xlast, ystart, xlast, ystop)
|
|
|
|
self.doc.draw_line('DC2-line', xlast, ystop, xnext, ystop)
|
|
|
|
|
|
|
|
if x%2:
|
2008-01-06 01:40:26 +05:30
|
|
|
phys_x +=1
|
2005-12-06 12:08:09 +05:30
|
|
|
phys_y += 1
|
|
|
|
|
|
|
|
if not self.force_fit:
|
|
|
|
self.doc.draw_text('DC2-box',
|
2009-01-20 14:40:01 +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)
|
2005-12-06 12:08:09 +05:30
|
|
|
self.doc.end_page()
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2008-03-02 04:17:48 +05:30
|
|
|
# DescendTreeOptions
|
2005-12-06 12:08:09 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2008-03-02 04:17:48 +05:30
|
|
|
class DescendTreeOptions(MenuReportOptions):
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
|
|
|
|
2008-01-24 18:20:33 +05:30
|
|
|
def __init__(self, name, dbase):
|
|
|
|
MenuReportOptions.__init__(self, name, dbase)
|
2007-03-03 08:42:04 +05:30
|
|
|
|
2008-01-24 18:20:33 +05:30
|
|
|
def add_menu_options(self, menu):
|
2008-01-06 02:12:05 +05:30
|
|
|
"""
|
|
|
|
Add options to the menu for the descendant report.
|
|
|
|
"""
|
2008-03-02 04:17:48 +05:30
|
|
|
category_name = _("Tree Options")
|
2007-09-05 08:32:50 +05:30
|
|
|
|
2008-01-18 11:09:50 +05:30
|
|
|
pid = PersonOption(_("Center Person"))
|
2008-03-02 04:17:48 +05:30
|
|
|
pid.set_help(_("The center person for the tree"))
|
2008-01-18 11:09:50 +05:30
|
|
|
menu.add_option(category_name, "pid", pid)
|
|
|
|
|
2008-03-02 04:17:48 +05:30
|
|
|
max_gen = NumberOption(_("Generations"), 10, 1, 50)
|
|
|
|
max_gen.set_help(_("The number of generations to include in the tree"))
|
|
|
|
menu.add_option(category_name, "maxgen", max_gen)
|
2007-09-05 08:32:50 +05:30
|
|
|
|
|
|
|
disp = TextOption( _("Display Format"),
|
|
|
|
["$n","%s $b" % _BORN,"%s $d" %_DIED] )
|
|
|
|
disp.set_help(_("Display format for the outputbox."))
|
2008-03-02 04:17:48 +05:30
|
|
|
menu.add_option(category_name, "dispf", disp)
|
2007-09-05 08:32:50 +05:30
|
|
|
|
2008-03-02 04:17:48 +05:30
|
|
|
scale = BooleanOption(_('Sc_ale to fit on a single page'), True)
|
2007-09-05 08:32:50 +05:30
|
|
|
scale.set_help(_("Whether to scale to fit on a single page."))
|
2008-03-02 04:17:48 +05:30
|
|
|
menu.add_option(category_name, "singlep", scale)
|
2007-09-05 08:32:50 +05:30
|
|
|
|
2008-03-02 04:17:48 +05:30
|
|
|
blank = BooleanOption(_('Include Blank Pages'), True)
|
2007-09-05 08:32:50 +05:30
|
|
|
blank.set_help(_("Whether to include pages that are blank."))
|
2008-03-02 04:17:48 +05:30
|
|
|
menu.add_option(category_name, "incblank", blank)
|
2007-09-05 08:32:50 +05:30
|
|
|
|
2009-01-20 14:40:01 +05:30
|
|
|
shows = BooleanOption(_('Show Sp_ouses'), True)
|
|
|
|
shows.set_help(_("Whether to show spouses in the tree."))
|
|
|
|
menu.add_option(category_name, "shows", shows)
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
def make_default_style(self,default_style):
|
2008-03-02 04:17:48 +05:30
|
|
|
"""Make the default output style for the Ancestor Tree."""
|
2007-04-23 17:16:26 +05:30
|
|
|
## Paragraph Styles:
|
2005-12-06 12:08:09 +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.'))
|
2009-01-20 14:40:01 +05:30
|
|
|
default_style.add_paragraph_style("DC2-Normal", p)
|
2005-12-06 12:08:09 +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.'))
|
2009-01-20 14:40:01 +05:30
|
|
|
default_style.add_paragraph_style("DC2-Title", p)
|
2007-04-23 17:16:26 +05:30
|
|
|
|
|
|
|
## Draw styles
|
|
|
|
g = BaseDoc.GraphicsStyle()
|
|
|
|
g.set_paragraph_style("DC2-Normal")
|
2009-01-20 14:40:01 +05:30
|
|
|
g.set_shadow(1, 0.2)
|
|
|
|
g.set_fill_color((255, 255, 255))
|
|
|
|
default_style.add_draw_style("DC2-box", g)
|
2007-04-23 17:16:26 +05:30
|
|
|
|
|
|
|
g = BaseDoc.GraphicsStyle()
|
|
|
|
g.set_paragraph_style("DC2-Title")
|
2009-01-20 14:40:01 +05:30
|
|
|
g.set_color((0, 0, 0))
|
|
|
|
g.set_fill_color((255, 255, 255))
|
2007-04-23 17:16:26 +05:30
|
|
|
g.set_line_width(0)
|
2009-01-20 14:40:01 +05:30
|
|
|
default_style.add_draw_style("DC2-title", g)
|
2007-04-23 17:16:26 +05:30
|
|
|
|
|
|
|
g = BaseDoc.GraphicsStyle()
|
2009-01-20 14:40:01 +05:30
|
|
|
default_style.add_draw_style("DC2-line", g)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2008-05-19 00:54:28 +05:30
|
|
|
pmgr = PluginManager.get_instance()
|
|
|
|
pmgr.register_report(
|
2007-09-05 08:32:50 +05:30
|
|
|
name = 'descend_chart',
|
2006-06-01 10:09:40 +05:30
|
|
|
category = CATEGORY_DRAW,
|
2008-03-02 04:17:48 +05:30
|
|
|
report_class = DescendTree,
|
|
|
|
options_class = DescendTreeOptions,
|
2008-10-02 09:32:10 +05:30
|
|
|
modes = PluginManager.REPORT_MODE_GUI | \
|
|
|
|
PluginManager.REPORT_MODE_BKI | \
|
|
|
|
PluginManager.REPORT_MODE_CLI,
|
2008-03-02 04:17:48 +05:30
|
|
|
translated_name = _("Descendant Tree"),
|
2005-12-06 12:08:09 +05:30
|
|
|
status = _("Stable"),
|
|
|
|
author_name = "Donald N. Allingham",
|
|
|
|
author_email = "don@gramps-project.org",
|
2008-03-02 04:17:48 +05:30
|
|
|
description = _("Produces a graphical descendant tree"),
|
2005-12-06 12:08:09 +05:30
|
|
|
)
|