2003-06-13 09:30:24 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-05-05 07:34:30 +05:30
|
|
|
# Copyright (C) 2003-2004 Donald N. Allingham
|
2003-06-13 09:30:24 +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-05-05 07:34:30 +05:30
|
|
|
# $Id$
|
|
|
|
|
2003-06-13 09:30:24 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gnome/gtk
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-08-30 04:17:06 +05:30
|
|
|
import BaseDoc
|
2003-06-13 09:30:24 +05:30
|
|
|
import Report
|
|
|
|
import Errors
|
|
|
|
import Calendar
|
|
|
|
|
|
|
|
from QuestionDialog import ErrorDialog
|
|
|
|
from FontScale import string_width
|
|
|
|
from SubstKeywords import SubstKeywords
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# pt2cm - convert points to centimeters
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def pt2cm(pt):
|
|
|
|
return (float(pt)/72.0)*(254.0/100.0)
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# FanChart
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class FanChart:
|
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
def __init__(self,database,person,display,doc,output,newpage=0):
|
2004-05-05 07:34:30 +05:30
|
|
|
self.database = database
|
2003-06-13 09:30:24 +05:30
|
|
|
self.doc = doc
|
2004-02-14 11:10:30 +05:30
|
|
|
self.doc.creator(database.get_researcher().get_name())
|
2003-06-13 09:30:24 +05:30
|
|
|
self.map = {}
|
|
|
|
self.text = {}
|
|
|
|
self.start = person
|
|
|
|
self.output = output
|
2004-05-05 07:34:30 +05:30
|
|
|
self.box_width = 0
|
|
|
|
self.height = 0
|
2003-06-13 09:30:24 +05:30
|
|
|
self.lines = 0
|
|
|
|
self.display = display
|
2003-08-30 04:17:06 +05:30
|
|
|
self.newpage = newpage
|
|
|
|
if output:
|
|
|
|
self.standalone = 1
|
|
|
|
self.doc.open(output)
|
|
|
|
else:
|
|
|
|
self.standalone = 0
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
|
|
|
g.set_paragraph_style('FC-Title')
|
2003-09-13 10:26:04 +05:30
|
|
|
g.set_line_width(0)
|
2003-06-13 09:30:24 +05:30
|
|
|
self.doc.add_draw_style("t",g)
|
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_fill_color((255,212,210))
|
2003-08-30 04:17:06 +05:30
|
|
|
g.set_paragraph_style('FC-Normal')
|
|
|
|
self.doc.add_draw_style("FC-c1",g)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_fill_color((255,212,210))
|
2003-08-30 04:17:06 +05:30
|
|
|
g.set_paragraph_style('FC-Normal')
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_line_width(0)
|
2003-08-30 04:17:06 +05:30
|
|
|
self.doc.add_draw_style("FC-c1n",g)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_fill_color((251,204,158))
|
2003-08-30 04:17:06 +05:30
|
|
|
g.set_paragraph_style('FC-Normal')
|
|
|
|
self.doc.add_draw_style("FC-c2",g)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_fill_color((251,204,158))
|
2003-08-30 04:17:06 +05:30
|
|
|
g.set_paragraph_style('FC-Normal')
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_line_width(0)
|
2003-08-30 04:17:06 +05:30
|
|
|
self.doc.add_draw_style("FC-c2n",g)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_fill_color((255,255,111))
|
2003-08-30 04:17:06 +05:30
|
|
|
g.set_paragraph_style('FC-Normal')
|
|
|
|
self.doc.add_draw_style("FC-c3",g)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_fill_color((255,255,111))
|
2003-08-30 04:17:06 +05:30
|
|
|
g.set_paragraph_style('FC-Normal')
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_line_width(0)
|
2003-08-30 04:17:06 +05:30
|
|
|
self.doc.add_draw_style("FC-c3n",g)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_fill_color((158,255,158))
|
2003-08-30 04:17:06 +05:30
|
|
|
g.set_paragraph_style('FC-Normal')
|
|
|
|
self.doc.add_draw_style("FC-c4",g)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_fill_color((158,255,158))
|
2003-08-30 04:17:06 +05:30
|
|
|
g.set_paragraph_style('FC-Normal')
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_line_width(0)
|
2003-08-30 04:17:06 +05:30
|
|
|
self.doc.add_draw_style("FC-c4n",g)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_fill_color((156,205,255))
|
2003-08-30 04:17:06 +05:30
|
|
|
g.set_paragraph_style('FC-Normal')
|
|
|
|
self.doc.add_draw_style("FC-c5",g)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_fill_color((156,205,255))
|
2003-08-30 04:17:06 +05:30
|
|
|
g.set_paragraph_style('FC-Normal')
|
2003-06-13 09:30:24 +05:30
|
|
|
g.set_line_width(0)
|
2003-08-30 04:17:06 +05:30
|
|
|
self.doc.add_draw_style("FC-c5n",g)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
self.map = [None] * 32
|
2004-05-05 07:34:30 +05:30
|
|
|
self.text= {}
|
2003-06-13 09:30:24 +05:30
|
|
|
self.box_width = 0
|
2003-09-13 10:26:04 +05:30
|
|
|
if self.standalone:
|
|
|
|
self.doc.init()
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
def filter(self,person_id,index):
|
2003-06-13 09:30:24 +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-05-05 07:34:30 +05:30
|
|
|
if (not person_id) or (index >= 32):
|
2003-06-13 09:30:24 +05:30
|
|
|
return
|
2004-05-05 07:34:30 +05:30
|
|
|
self.map[index-1] = person_id
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
self.text[index-1] = []
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
subst = SubstKeywords(self.database,person_id)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
for line in self.display:
|
|
|
|
self.text[index-1].append(subst.replace(line))
|
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
self.font = self.doc.style_list["FC-Normal"].get_font()
|
2004-05-05 07:34:30 +05:30
|
|
|
for line in self.text[index-1]:
|
|
|
|
self.box_width = max(self.box_width,string_width(self.font,line))
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
self.lines = max(self.lines,len(self.text[index-1]))
|
2003-06-13 09:30:24 +05:30
|
|
|
|
* src/RelLib.py (try_to_find_person_from_id): Remove transaction;
(try_to_find_source_from_id, try_to_find_object_from_id,
try_to_find_place_from_id): Add functions.
* src/plugins/WriteCD.py, src/plugins/WritePkg.py,
src/plugins/WebPage.py, src/plugins/Verify.py,
src/plugins/TimeLine.py, src/plugins/Summary.py,
src/plugins/SoundGen.py, src/plugins/RelGraph.py,
src/plugins/RelCalc.py, src/plugins/PatchNames.py,
src/plugins/Merge.py, src/plugins/IndivSummary.py,
src/plugins/IndivComplete.py, src/plugins/GraphViz.py,
src/plugins/FtmStyleDescendants.py,
src/plugins/FtmStyleAncestors.py, src/plugins/FilterEditor.py,
src/plugins/FanChart.py, src/plugins/FamilyGroup.py,
src/plugins/EventCmp.py, src/plugins/DetDescendantReport.py,
src/plugins/DetAncestralReport.py, src/plugins/DescendReport.py,
src/plugins/Desbrowser.py, src/plugins/CountAncestors.py,
src/plugins/Check.py, src/plugins/ChangeTypes.py,
src/plugins/BookReport.py, src/plugins/Ancestors.py,
src/plugins/AncestorReport.py, src/plugins/AncestorChart.py,
src/plugins/AncestorChart2.py, src/Relationship.py,
src/Sort.py, src/GenericFilter.py, src/SubstKeywords.py,
src/GraphLayout.py: Switch from find_* to try_to_find_* methods.
svn: r3191
2004-05-26 07:35:02 +05:30
|
|
|
person = self.database.try_to_find_person_from_id(person_id)
|
2004-05-05 07:34:30 +05:30
|
|
|
family_id = person.get_main_parents_family_id()
|
|
|
|
if family_id:
|
|
|
|
family = self.database.find_family_from_id(family_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.filter(family.get_father_id(),index*2)
|
|
|
|
self.filter(family.get_mother_id(),(index*2)+1)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
def write_report(self):
|
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
self.filter(self.start.get_id(),1)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
block_size = self.doc.get_usable_width()/14.0
|
2003-08-30 04:17:06 +05:30
|
|
|
|
|
|
|
if self.newpage:
|
|
|
|
self.doc.page_break()
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
size = min(self.doc.get_usable_width(),self.doc.get_usable_height()*2.0)/2.0
|
|
|
|
y = self.doc.get_usable_height()
|
|
|
|
max_lines = int(size/block_size)
|
|
|
|
center = (self.doc.get_usable_width()/2.0)
|
|
|
|
|
|
|
|
self.doc.start_page()
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
n = self.start.get_primary_name().get_regular_name()
|
2003-06-13 09:30:24 +05:30
|
|
|
self.doc.center_text('t', _('Five Generation Fan Chart for %s') % n, center, 0)
|
|
|
|
|
|
|
|
self.circle_5(center,y,block_size)
|
|
|
|
self.circle_4(center,y,block_size)
|
|
|
|
self.circle_3(center,y,block_size)
|
|
|
|
self.circle_2(center,y,block_size)
|
|
|
|
self.circle_1(center,y,block_size)
|
|
|
|
|
|
|
|
self.doc.end_page()
|
2003-08-30 04:17:06 +05:30
|
|
|
if self.standalone:
|
2003-06-13 09:30:24 +05:30
|
|
|
self.doc.close()
|
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
def get_info(self,person_id):
|
* src/RelLib.py (try_to_find_person_from_id): Remove transaction;
(try_to_find_source_from_id, try_to_find_object_from_id,
try_to_find_place_from_id): Add functions.
* src/plugins/WriteCD.py, src/plugins/WritePkg.py,
src/plugins/WebPage.py, src/plugins/Verify.py,
src/plugins/TimeLine.py, src/plugins/Summary.py,
src/plugins/SoundGen.py, src/plugins/RelGraph.py,
src/plugins/RelCalc.py, src/plugins/PatchNames.py,
src/plugins/Merge.py, src/plugins/IndivSummary.py,
src/plugins/IndivComplete.py, src/plugins/GraphViz.py,
src/plugins/FtmStyleDescendants.py,
src/plugins/FtmStyleAncestors.py, src/plugins/FilterEditor.py,
src/plugins/FanChart.py, src/plugins/FamilyGroup.py,
src/plugins/EventCmp.py, src/plugins/DetDescendantReport.py,
src/plugins/DetAncestralReport.py, src/plugins/DescendReport.py,
src/plugins/Desbrowser.py, src/plugins/CountAncestors.py,
src/plugins/Check.py, src/plugins/ChangeTypes.py,
src/plugins/BookReport.py, src/plugins/Ancestors.py,
src/plugins/AncestorReport.py, src/plugins/AncestorChart.py,
src/plugins/AncestorChart2.py, src/Relationship.py,
src/Sort.py, src/GenericFilter.py, src/SubstKeywords.py,
src/GraphLayout.py: Switch from find_* to try_to_find_* methods.
svn: r3191
2004-05-26 07:35:02 +05:30
|
|
|
person = self.database.try_to_find_person_from_id(person_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
pn = person.get_primary_name()
|
2004-05-05 07:34:30 +05:30
|
|
|
|
|
|
|
birth_id = person.get_birth_id()
|
|
|
|
if birth_id:
|
|
|
|
b = self.database.find_event_from_id(birth_id).get_date_object().get_year()
|
|
|
|
if b == Calendar.UNDEF:
|
|
|
|
b = ""
|
|
|
|
else:
|
2003-06-13 09:30:24 +05:30
|
|
|
b = ""
|
2004-05-05 07:34:30 +05:30
|
|
|
|
|
|
|
death_id = person.get_death_id()
|
|
|
|
if death_id:
|
|
|
|
d = self.database.find_event_from_id(death_id).get_date_object().get_year()
|
|
|
|
if d == Calendar.UNDEF:
|
|
|
|
d = ""
|
|
|
|
else:
|
2003-06-13 09:30:24 +05:30
|
|
|
d = ""
|
|
|
|
|
|
|
|
if b or d:
|
|
|
|
val = "%s - %s" % (str(b),str(d))
|
|
|
|
else:
|
|
|
|
val = ""
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
return [ pn.get_first_name(), pn.get_surname(), val ]
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
def circle_1(self,center,y,size):
|
2003-08-30 04:17:06 +05:30
|
|
|
(xc,yc) = self.doc.draw_wedge("FC-c1", center, y, size, 180, 360)
|
|
|
|
self.doc.rotate_text("FC-c1n", self.get_info(self.map[0]), xc, yc ,0)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
def circle_2(self,center,y,size):
|
2003-08-30 04:17:06 +05:30
|
|
|
(xc,yc) = self.doc.draw_wedge("FC-c2", center, y, size*2, 180, 270, size)
|
2003-06-13 09:30:24 +05:30
|
|
|
if self.map[1]:
|
2003-08-30 04:17:06 +05:30
|
|
|
self.doc.rotate_text("FC-c2n", self.get_info(self.map[1]), xc, yc, -45)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
(xc,yc) = self.doc.draw_wedge("FC-c2", center, y, size*2, 270, 360, size)
|
2003-06-13 09:30:24 +05:30
|
|
|
if self.map[2]:
|
2003-08-30 04:17:06 +05:30
|
|
|
self.doc.rotate_text("FC-c2n", self.get_info(self.map[2]), xc,yc ,45)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
def circle_3(self,center,y,size):
|
|
|
|
delta = 45
|
|
|
|
sangle = -67.5
|
|
|
|
for index in range(3,7):
|
|
|
|
start = 180+(index-3)*45
|
|
|
|
stop = start+45
|
2003-08-30 04:17:06 +05:30
|
|
|
(xc,yc) = self.doc.draw_wedge("FC-c3", center, y, size*3, start, stop, size*2)
|
2003-06-13 09:30:24 +05:30
|
|
|
if self.map[index]:
|
2003-08-30 04:17:06 +05:30
|
|
|
self.doc.rotate_text("FC-c3n", self.get_info(self.map[index]),
|
2003-06-13 09:30:24 +05:30
|
|
|
xc,yc ,sangle)
|
|
|
|
sangle += 45
|
|
|
|
|
|
|
|
def circle_4(self,center,y,size):
|
|
|
|
delta = 22.5
|
|
|
|
sangle = -78.75 + 90
|
|
|
|
for i in range(0,8):
|
|
|
|
start_angle = 180 + (i * delta)
|
|
|
|
end_angle = 180 + ((i+1) * delta)
|
2003-08-30 04:17:06 +05:30
|
|
|
(xc,yc) = self.doc.draw_wedge("FC-c4", center, y, size*5, start_angle,
|
2003-06-13 09:30:24 +05:30
|
|
|
end_angle, size*3)
|
|
|
|
if i == 4:
|
|
|
|
sangle += 180
|
|
|
|
if self.map[i+7]:
|
2003-08-30 04:17:06 +05:30
|
|
|
self.doc.rotate_text("FC-c4n", self.get_info(self.map[i+7]),
|
2003-06-13 09:30:24 +05:30
|
|
|
xc,yc ,sangle)
|
|
|
|
sangle += 22.5
|
|
|
|
|
|
|
|
def circle_5(self,center,y,size):
|
|
|
|
delta = 11.25
|
|
|
|
sangle = -84.625 + 90
|
|
|
|
for i in range(0,16):
|
|
|
|
start_angle = 180 + (i * delta)
|
|
|
|
end_angle = 180 + ((i+1) * delta)
|
2003-08-30 04:17:06 +05:30
|
|
|
(xc,yc) = self.doc.draw_wedge("FC-c5", center, y, size*7, start_angle,
|
2003-06-13 09:30:24 +05:30
|
|
|
end_angle, size*5)
|
|
|
|
if i == 8:
|
|
|
|
sangle += 180
|
|
|
|
if self.map[i+15]:
|
2003-08-30 04:17:06 +05:30
|
|
|
self.doc.rotate_text("FC-c5n", self.get_info(self.map[i+15]),
|
2003-06-13 09:30:24 +05:30
|
|
|
xc,yc ,sangle)
|
|
|
|
sangle += 11.25
|
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def _make_default_style(default_style):
|
|
|
|
"""Make the default output style for the Fan Chart report."""
|
|
|
|
f = BaseDoc.FontStyle()
|
|
|
|
f.set_size(8)
|
|
|
|
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 text display.'))
|
|
|
|
default_style.add_style("FC-Normal",p)
|
|
|
|
|
|
|
|
f = BaseDoc.FontStyle()
|
|
|
|
f.set_size(20)
|
|
|
|
f.set_bold(1)
|
|
|
|
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 style used for the title.'))
|
|
|
|
default_style.add_style("FC-Title",p)
|
|
|
|
|
2003-06-13 09:30:24 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# FanChartDialog
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class FanChartDialog(Report.DrawReportDialog):
|
2003-10-31 06:53:16 +05:30
|
|
|
|
|
|
|
report_options = {}
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
def __init__(self,database,person):
|
2003-10-31 06:53:16 +05:30
|
|
|
Report.DrawReportDialog.__init__(self,database,person,self.report_options)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
def get_title(self):
|
|
|
|
"""The window title for this dialog"""
|
|
|
|
return "%s - %s - GRAMPS" % (_("Fan Chart"),_("Graphical Reports"))
|
|
|
|
|
|
|
|
def get_header(self, name):
|
|
|
|
"""The header line at the top of the dialog contents."""
|
|
|
|
return _("Fan Chart for %s") % name
|
|
|
|
|
|
|
|
def get_target_browser_title(self):
|
|
|
|
"""The title of the window created when the 'browse' button is
|
|
|
|
clicked in the 'Save As' frame."""
|
|
|
|
return _("Save Fan Chart")
|
|
|
|
|
|
|
|
def get_stylesheet_savefile(self):
|
|
|
|
"""Where to save user defined styles for this report."""
|
2003-08-30 04:17:06 +05:30
|
|
|
return _style_file
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
def get_report_generations(self):
|
|
|
|
"""Default to 10 generations, no page breaks."""
|
|
|
|
return (0, 0)
|
|
|
|
|
|
|
|
def make_default_style(self):
|
2003-08-30 04:17:06 +05:30
|
|
|
_make_default_style(self.default_style)
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
def make_report(self):
|
2003-08-30 05:45:10 +05:30
|
|
|
"""Create the object that will produce the Fan Chart.
|
2003-06-13 09:30:24 +05:30
|
|
|
All user dialog has already been handled and the output file
|
|
|
|
opened."""
|
|
|
|
|
|
|
|
try:
|
2003-08-30 04:17:06 +05:30
|
|
|
MyReport = FanChart(self.db, self.person,
|
|
|
|
"%n", self.doc, self.target_path)
|
2003-06-13 09:30:24 +05:30
|
|
|
MyReport.write_report()
|
|
|
|
except Errors.FilterError, msg:
|
|
|
|
(m1,m2) = msg.messages()
|
|
|
|
ErrorDialog(m1,m2)
|
|
|
|
except:
|
|
|
|
import DisplayTrace
|
|
|
|
DisplayTrace.DisplayTrace()
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Entry point of the report. Takes the database and the active person
|
|
|
|
# as its arguments.
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def report(database,person):
|
|
|
|
FanChartDialog(database,person)
|
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Set up sane defaults for the book_item
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
_style_file = "fan_chart.xml"
|
|
|
|
_style_name = "default"
|
|
|
|
|
|
|
|
_person_id = ""
|
|
|
|
_options = ( _person_id, )
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Book Item Options dialog
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class FanChartBareDialog(Report.BareReportDialog):
|
|
|
|
|
|
|
|
def __init__(self,database,person,opt,stl):
|
|
|
|
|
|
|
|
self.options = opt
|
|
|
|
self.db = database
|
|
|
|
if self.options[0]:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person = self.db.get_person(self.options[0])
|
2003-08-30 04:17:06 +05:30
|
|
|
else:
|
|
|
|
self.person = person
|
|
|
|
self.style_name = stl
|
|
|
|
|
|
|
|
Report.BareReportDialog.__init__(self,database,self.person)
|
|
|
|
self.new_person = None
|
|
|
|
self.window.run()
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Customization hooks
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def get_title(self):
|
|
|
|
"""The window title for this dialog"""
|
|
|
|
return "%s - GRAMPS Book" % (_("Fan Chart"))
|
|
|
|
|
|
|
|
def get_header(self, name):
|
|
|
|
"""The header line at the top of the dialog contents"""
|
|
|
|
return _("Fan Chart for GRAMPS Book")
|
|
|
|
|
|
|
|
def get_stylesheet_savefile(self):
|
|
|
|
"""Where to save styles for this report."""
|
|
|
|
return _style_file
|
|
|
|
|
|
|
|
def get_report_generations(self):
|
|
|
|
"""No generations, no page breaks."""
|
|
|
|
return (0, 0)
|
|
|
|
|
|
|
|
def make_default_style(self):
|
|
|
|
_make_default_style(self.default_style)
|
|
|
|
|
|
|
|
def on_cancel(self, obj):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_ok_clicked(self, obj):
|
|
|
|
"""The user is satisfied with the dialog choices. Parse all options
|
|
|
|
and close the window."""
|
|
|
|
|
|
|
|
# Preparation
|
|
|
|
self.parse_style_frame()
|
|
|
|
|
|
|
|
if self.new_person:
|
|
|
|
self.person = self.new_person
|
2004-02-14 11:10:30 +05:30
|
|
|
self.options = ( self.person.get_id(), )
|
2003-08-30 04:17:06 +05:30
|
|
|
self.style_name = self.selected_style.get_name()
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Function to write Book Item
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def write_book_item(database,person,doc,options,newpage=0):
|
|
|
|
"""Write the Fan Chart using options set.
|
|
|
|
All user dialog has already been handled and the output file opened."""
|
|
|
|
try:
|
|
|
|
if options[0]:
|
2004-02-14 11:10:30 +05:30
|
|
|
person = database.get_person(options[0])
|
2003-08-30 04:17:06 +05:30
|
|
|
return FanChart(database, person,
|
|
|
|
"%n", doc, None, newpage )
|
|
|
|
except Errors.ReportError, msg:
|
|
|
|
(m1,m2) = msg.messages()
|
|
|
|
ErrorDialog(m1,m2)
|
|
|
|
except Errors.FilterError, msg:
|
|
|
|
(m1,m2) = msg.messages()
|
|
|
|
ErrorDialog(m1,m2)
|
|
|
|
except:
|
|
|
|
import DisplayTrace
|
|
|
|
DisplayTrace.DisplayTrace()
|
|
|
|
|
2003-06-13 09:30:24 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Register the report with the plugin system. If this is not done, then
|
|
|
|
# GRAMPS will not know that the report exists.
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-08-30 04:17:06 +05:30
|
|
|
from Plugins import register_report, register_book_item
|
2003-06-13 09:30:24 +05:30
|
|
|
|
|
|
|
register_report(
|
|
|
|
report,
|
|
|
|
_("Fan Chart"),
|
|
|
|
category=_("Graphical Reports"),
|
|
|
|
status=(_("Alpha")),
|
|
|
|
description=_("Produces a five generation fan chart")
|
|
|
|
)
|
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
# (name,category,options_dialog,write_book_item,options,style_name,style_file,make_default_style)
|
|
|
|
register_book_item(
|
|
|
|
_("Fan Chart"),
|
|
|
|
_("Graphics"),
|
|
|
|
FanChartBareDialog,
|
|
|
|
write_book_item,
|
|
|
|
_options,
|
|
|
|
_style_name,
|
|
|
|
_style_file,
|
|
|
|
_make_default_style
|
|
|
|
)
|