2003-02-09 05:15:21 +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-02-09 05:15:21 +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
|
|
|
|
#
|
|
|
|
|
2003-12-17 21:36:36 +05:30
|
|
|
# $Id$
|
|
|
|
|
2003-02-09 05:15:21 +05:30
|
|
|
"""
|
2003-02-13 10:45:39 +05:30
|
|
|
Timeline report
|
2003-02-09 05:15:21 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import os
|
2004-12-22 07:26:37 +05:30
|
|
|
from gettext import gettext as _
|
2003-02-09 05:15:21 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME/gtk
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import Utils
|
|
|
|
import Report
|
2003-08-30 04:17:06 +05:30
|
|
|
import BaseDoc
|
2003-02-09 05:15:21 +05:30
|
|
|
import GenericFilter
|
|
|
|
import Errors
|
|
|
|
import Date
|
2004-05-05 07:34:30 +05:30
|
|
|
import Sort
|
2004-12-22 07:26:37 +05:30
|
|
|
import ReportOptions
|
2003-02-09 05:15:21 +05:30
|
|
|
from QuestionDialog import ErrorDialog
|
2004-12-22 07:26:37 +05:30
|
|
|
import const
|
2003-02-09 05:15:21 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# TimeLine
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class TimeLine:
|
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
def __init__(self,database,person,options_class):
|
2003-02-09 05:15:21 +05:30
|
|
|
"""
|
2004-12-22 07:26:37 +05:30
|
|
|
Creates the Timeline 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.
|
|
|
|
|
|
|
|
filter - Filter to be applied to the people of the database.
|
|
|
|
The option class carries its number, and the function
|
|
|
|
returning the list of filters.
|
|
|
|
title - Title of the report displayed on top
|
|
|
|
sort_func - function used to sort entries, that returns -1/0/1
|
|
|
|
when given two personal handles (like cmp).
|
|
|
|
The option class carries its number, and the function
|
|
|
|
returning the list of sort functions.
|
|
|
|
document - BaseDoc instance for the output file. Any class derived
|
|
|
|
from BaseDoc may be used
|
|
|
|
output - name of the output file.
|
|
|
|
None if report is not a standalone, in which case
|
|
|
|
somebody must take care of opening and initializing report
|
|
|
|
prior to writing.
|
|
|
|
newpage - if True, newpage is made before writing a report
|
|
|
|
|
2003-02-09 05:15:21 +05:30
|
|
|
"""
|
2004-12-22 07:26:37 +05:30
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
self.db = database
|
|
|
|
self.person = person
|
2004-12-22 07:26:37 +05:30
|
|
|
self.options_class = options_class
|
|
|
|
|
2004-12-23 23:09:47 +05:30
|
|
|
filter_num = options_class.get_filter_number()
|
2004-12-22 07:26:37 +05:30
|
|
|
filters = options_class.get_report_filters(person)
|
|
|
|
self.filter = filters[filter_num]
|
|
|
|
|
|
|
|
self.title = options_class.handler.options_dict['title']
|
|
|
|
|
|
|
|
sort_func_num = options_class.handler.options_dict['sortby']
|
|
|
|
sort_functions = options_class.get_sort_functions(Sort.Sort(database))
|
|
|
|
self.sort_func = sort_functions[sort_func_num][1]
|
|
|
|
|
2004-12-23 23:09:47 +05:30
|
|
|
self.d = options_class.get_document()
|
|
|
|
self.output = options_class.get_output()
|
|
|
|
self.newpage = options_class.get_newpage()
|
2004-12-22 07:26:37 +05:30
|
|
|
|
2003-08-30 05:45:10 +05:30
|
|
|
self.setup()
|
2004-12-22 07:26:37 +05:30
|
|
|
if self.output:
|
2003-08-30 04:17:06 +05:30
|
|
|
self.standalone = 1
|
2004-12-22 07:26:37 +05:30
|
|
|
self.d.open(self.output)
|
2003-09-15 08:24:07 +05:30
|
|
|
self.d.init()
|
2003-08-30 04:17:06 +05:30
|
|
|
else:
|
|
|
|
self.standalone = 0
|
2003-02-09 05:15:21 +05:30
|
|
|
|
|
|
|
def setup(self):
|
|
|
|
"""
|
|
|
|
Define the graphics styles used by the report. Paragraph definitions
|
|
|
|
have already been defined in the document. The styles used are:
|
|
|
|
|
2003-08-30 05:45:10 +05:30
|
|
|
TLG-grid - 0.5pt wide line dashed line. Used for the lines that make up
|
2003-02-09 05:15:21 +05:30
|
|
|
the grid.
|
2003-08-30 05:45:10 +05:30
|
|
|
TLG-line - 0.5pt wide line. Used for the line connecting two endpoints
|
2003-02-09 05:15:21 +05:30
|
|
|
and for the birth marker.
|
2003-08-30 05:45:10 +05:30
|
|
|
TLG-solid - 0.5pt line with a black fill color. Used for the date of
|
2003-02-09 05:15:21 +05:30
|
|
|
death marker.
|
2003-08-30 05:45:10 +05:30
|
|
|
TLG-text - Contains the TLG-Name paragraph style used for the individual's
|
2003-02-09 05:15:21 +05:30
|
|
|
name
|
2003-08-30 05:45:10 +05:30
|
|
|
TLG-title - Contains the TLG-Title paragraph style used for the title of
|
2003-02-09 05:15:21 +05:30
|
|
|
the document
|
2003-08-30 05:45:10 +05:30
|
|
|
TLG-label - Contains the TLG-Label paragraph style used for the year label's
|
2003-02-09 05:15:21 +05:30
|
|
|
in the document.
|
|
|
|
"""
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-02-09 05:15:21 +05:30
|
|
|
g.set_line_width(0.5)
|
|
|
|
g.set_color((0,0,0))
|
2003-08-30 05:45:10 +05:30
|
|
|
self.d.add_draw_style("TLG-line",g)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-02-09 05:15:21 +05:30
|
|
|
g.set_line_width(0.5)
|
|
|
|
g.set_color((0,0,0))
|
|
|
|
g.set_fill_color((0,0,0))
|
2003-08-30 05:45:10 +05:30
|
|
|
self.d.add_draw_style("TLG-solid",g)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-02-09 05:15:21 +05:30
|
|
|
g.set_line_width(0.5)
|
|
|
|
g.set_color((0,0,0))
|
|
|
|
g.set_fill_color((255,255,255))
|
|
|
|
self.d.add_draw_style("open",g)
|
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-02-09 05:15:21 +05:30
|
|
|
g.set_line_width(0.5)
|
2003-08-30 04:17:06 +05:30
|
|
|
g.set_line_style(BaseDoc.DASHED)
|
2003-02-09 05:15:21 +05:30
|
|
|
g.set_color((0,0,0))
|
2003-08-30 05:45:10 +05:30
|
|
|
self.d.add_draw_style("TLG-grid",g)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-08-30 05:45:10 +05:30
|
|
|
g.set_paragraph_style("TLG-Name")
|
2003-02-09 05:15:21 +05:30
|
|
|
g.set_color((255,255,255))
|
|
|
|
g.set_fill_color((255,255,255))
|
|
|
|
g.set_line_width(0)
|
2003-08-30 05:45:10 +05:30
|
|
|
self.d.add_draw_style("TLG-text",g)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-08-30 05:45:10 +05:30
|
|
|
g.set_paragraph_style("TLG-Title")
|
2003-02-09 05:15:21 +05:30
|
|
|
g.set_color((255,255,255))
|
|
|
|
g.set_fill_color((255,255,255))
|
|
|
|
g.set_line_width(0)
|
2004-01-10 23:34:32 +05:30
|
|
|
g.set_width(self.d.get_usable_width())
|
2003-08-30 05:45:10 +05:30
|
|
|
self.d.add_draw_style("TLG-title",g)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
g = BaseDoc.GraphicsStyle()
|
2003-08-30 05:45:10 +05:30
|
|
|
g.set_paragraph_style("TLG-Label")
|
2003-02-09 05:15:21 +05:30
|
|
|
g.set_color((255,255,255))
|
|
|
|
g.set_fill_color((255,255,255))
|
|
|
|
g.set_line_width(0)
|
2003-08-30 05:45:10 +05:30
|
|
|
self.d.add_draw_style("TLG-label",g)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
|
|
|
def write_report(self):
|
|
|
|
|
|
|
|
(low,high) = self.find_year_range()
|
2003-03-12 08:32:08 +05:30
|
|
|
|
2004-11-28 10:33:29 +05:30
|
|
|
if low == high:
|
|
|
|
if self.standalone:
|
|
|
|
self.d.close()
|
|
|
|
ErrorDialog(_("Report could not be created"),
|
|
|
|
_("The range of dates chosen was not valid"))
|
|
|
|
return
|
|
|
|
|
2003-02-09 05:15:21 +05:30
|
|
|
st_size = self.name_size()
|
|
|
|
|
2003-08-30 05:45:10 +05:30
|
|
|
font = self.d.style_list['TLG-Name'].get_font()
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
incr = Utils.pt2cm(font.get_size())
|
2003-02-09 05:15:21 +05:30
|
|
|
pad = incr*.75
|
|
|
|
|
|
|
|
x1,x2,y1,y2 = (0,0,0,0)
|
|
|
|
|
|
|
|
start = st_size+0.5
|
|
|
|
stop = self.d.get_usable_width()-0.5
|
|
|
|
size = (stop-start)
|
|
|
|
self.header = 2.0
|
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
if self.newpage:
|
2003-08-30 08:07:53 +05:30
|
|
|
self.d.page_break()
|
2003-02-09 05:15:21 +05:30
|
|
|
self.d.start_page()
|
|
|
|
|
|
|
|
index = 1
|
|
|
|
current = 1;
|
|
|
|
|
|
|
|
length = len(self.plist)
|
|
|
|
|
|
|
|
self.plist.sort(self.sort_func)
|
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
for p_id in self.plist:
|
2004-08-07 10:46:57 +05:30
|
|
|
p = self.db.get_person_from_handle(p_id)
|
2004-07-28 07:59:07 +05:30
|
|
|
b_id = p.get_birth_handle()
|
2004-05-05 07:34:30 +05:30
|
|
|
if b_id:
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
b = self.db.get_event_from_handle(b_id).get_date_object().get_year()
|
2004-05-05 07:34:30 +05:30
|
|
|
else:
|
2004-10-22 21:05:47 +05:30
|
|
|
b = None
|
2004-05-05 07:34:30 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
d_id = p.get_death_handle()
|
2004-05-05 07:34:30 +05:30
|
|
|
if d_id:
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
d = self.db.get_event_from_handle(d_id).get_date_object().get_year()
|
2004-05-05 07:34:30 +05:30
|
|
|
else:
|
2004-10-22 21:05:47 +05:30
|
|
|
d = None
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
n = p.get_primary_name().get_name()
|
2003-08-30 05:45:10 +05:30
|
|
|
self.d.draw_text('TLG-text',n,incr+pad,self.header + (incr+pad)*index)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
|
|
|
y1 = self.header + (pad+incr)*index
|
|
|
|
y2 = self.header + ((pad+incr)*index)+incr
|
|
|
|
y3 = (y1+y2)/2.0
|
|
|
|
w = 0.05
|
|
|
|
|
2004-10-22 21:05:47 +05:30
|
|
|
if b:
|
2003-02-09 05:15:21 +05:30
|
|
|
start_offset = ((float(b-low)/float(high-low)) * (size))
|
|
|
|
x1 = start+start_offset
|
|
|
|
path = [(x1,y1),(x1+w,y3),(x1,y2),(x1-w,y3)]
|
2003-08-30 05:45:10 +05:30
|
|
|
self.d.draw_path('TLG-line',path)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-10-22 21:05:47 +05:30
|
|
|
if d:
|
2003-02-09 05:15:21 +05:30
|
|
|
start_offset = ((float(d-low)/float(high-low)) * (size))
|
|
|
|
x1 = start+start_offset
|
|
|
|
path = [(x1,y1),(x1+w,y3),(x1,y2),(x1-w,y3)]
|
2003-08-30 05:45:10 +05:30
|
|
|
self.d.draw_path('TLG-solid',path)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-10-22 21:05:47 +05:30
|
|
|
if b and d:
|
2003-02-09 05:15:21 +05:30
|
|
|
start_offset = ((float(b-low)/float(high-low)) * size) + w
|
|
|
|
stop_offset = ((float(d-low)/float(high-low)) * size) - w
|
|
|
|
|
|
|
|
x1 = start+start_offset
|
|
|
|
x2 = start+stop_offset
|
|
|
|
self.d.draw_line('open',x1,y3,x2,y3)
|
|
|
|
|
|
|
|
if (y2 + incr) >= self.d.get_usable_height():
|
|
|
|
if current != length:
|
2003-09-12 08:47:42 +05:30
|
|
|
self.build_grid(low,high,start,stop)
|
2003-02-09 05:15:21 +05:30
|
|
|
self.d.end_page()
|
|
|
|
self.d.start_page()
|
|
|
|
self.build_grid(low,high,start,stop)
|
|
|
|
index = 1
|
|
|
|
x1,x2,y1,y2 = (0,0,0,0)
|
|
|
|
else:
|
|
|
|
index += 1;
|
|
|
|
current += 1
|
|
|
|
|
2003-09-12 08:47:42 +05:30
|
|
|
self.build_grid(low,high,start,stop)
|
2003-02-09 05:15:21 +05:30
|
|
|
self.d.end_page()
|
2003-08-30 04:17:06 +05:30
|
|
|
if self.standalone:
|
|
|
|
self.d.close()
|
2003-02-09 05:15:21 +05:30
|
|
|
|
|
|
|
def build_grid(self,year_low,year_high,start_pos,stop_pos):
|
|
|
|
"""
|
|
|
|
Draws the grid outline for the chart. Sets the document label,
|
|
|
|
draws the vertical lines, and adds the year labels. Arguments
|
|
|
|
are:
|
|
|
|
|
|
|
|
year_low - lowest year on the chart
|
|
|
|
year_high - highest year on the chart
|
|
|
|
start_pos - x position of the lowest leftmost grid line
|
|
|
|
stop_pos - x position of the rightmost grid line
|
|
|
|
"""
|
|
|
|
width = self.d.get_usable_width()
|
|
|
|
|
2003-08-30 05:45:10 +05:30
|
|
|
title_font = self.d.style_list['TLG-Title'].get_font()
|
|
|
|
normal_font = self.d.style_list['TLG-Name'].get_font()
|
|
|
|
label_font = self.d.style_list['TLG-Label'].get_font()
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-01-10 23:34:32 +05:30
|
|
|
self.d.center_text('TLG-title',self.title,width/2.0,0)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
label_y = self.header - (Utils.pt2cm(normal_font.get_size())*1.2)
|
2003-02-09 05:15:21 +05:30
|
|
|
top_y = self.header
|
|
|
|
bottom_y = self.d.get_usable_height()
|
|
|
|
|
|
|
|
incr = (year_high - year_low)/5
|
|
|
|
delta = (stop_pos - start_pos)/ 5
|
|
|
|
|
|
|
|
for val in range(0,6):
|
|
|
|
year_str = str(year_low + (incr*val))
|
|
|
|
|
|
|
|
xpos = start_pos+(val*delta)
|
2004-01-10 23:34:32 +05:30
|
|
|
self.d.center_text('TLG-label', year_str, xpos, label_y)
|
2003-08-30 05:45:10 +05:30
|
|
|
self.d.draw_line('TLG-grid', xpos, top_y, xpos, bottom_y)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
|
|
|
def find_year_range(self):
|
|
|
|
low = 999999
|
2004-05-05 07:34:30 +05:30
|
|
|
high = -999999
|
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
self.plist = self.filter.apply(self.db,self.db.get_person_handles(sort_handles=False))
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
for p_id in self.plist:
|
2004-08-07 10:46:57 +05:30
|
|
|
p = self.db.get_person_from_handle(p_id)
|
2004-07-28 07:59:07 +05:30
|
|
|
b_id = p.get_birth_handle()
|
2004-05-05 07:34:30 +05:30
|
|
|
if b_id:
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
b = self.db.get_event_from_handle(b_id).get_date_object().get_year()
|
2004-05-05 07:34:30 +05:30
|
|
|
else:
|
2004-10-22 21:05:47 +05:30
|
|
|
b = None
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
d_id = p.get_death_handle()
|
2004-05-05 07:34:30 +05:30
|
|
|
if d_id:
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
d = self.db.get_event_from_handle(d_id).get_date_object().get_year()
|
2004-05-05 07:34:30 +05:30
|
|
|
else:
|
2004-10-22 21:05:47 +05:30
|
|
|
d = None
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-10-22 21:05:47 +05:30
|
|
|
if b:
|
2004-05-05 07:34:30 +05:30
|
|
|
low = min(low,b)
|
|
|
|
high = max(high,b)
|
|
|
|
|
2004-10-22 21:05:47 +05:30
|
|
|
if d:
|
2004-05-05 07:34:30 +05:30
|
|
|
low = min(low,d)
|
|
|
|
high = max(high,d)
|
2003-03-12 08:32:08 +05:30
|
|
|
|
2004-05-05 07:34:30 +05:30
|
|
|
low = (low/10)*10
|
|
|
|
high = ((high+9)/10)*10
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-10-22 21:05:47 +05:30
|
|
|
if low == None:
|
2003-03-12 08:32:08 +05:30
|
|
|
low = high
|
2004-10-22 21:05:47 +05:30
|
|
|
if high == None:
|
2003-03-12 08:32:08 +05:30
|
|
|
high = low
|
|
|
|
|
2003-02-09 05:15:21 +05:30
|
|
|
return (low,high)
|
|
|
|
|
|
|
|
def name_size(self):
|
2004-08-13 10:04:07 +05:30
|
|
|
self.plist = self.filter.apply(self.db,self.db.get_person_handles(sort_handles=False))
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2003-08-30 05:45:10 +05:30
|
|
|
style_name = self.d.draw_styles['TLG-text'].get_paragraph_style()
|
2003-02-09 05:15:21 +05:30
|
|
|
font = self.d.style_list[style_name].get_font()
|
|
|
|
|
|
|
|
size = 0
|
2004-05-05 07:34:30 +05:30
|
|
|
for p_id in self.plist:
|
2004-08-07 10:46:57 +05:30
|
|
|
p = self.db.get_person_from_handle(p_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
n = p.get_primary_name().get_name()
|
2004-08-21 02:56:51 +05:30
|
|
|
size = max(self.d.string_width(font,n),size)
|
2004-12-22 07:26:37 +05:30
|
|
|
return Utils.pt2cm(size)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2004-12-23 06:27:56 +05:30
|
|
|
class TimeLineOptions(ReportOptions.ReportOptions):
|
2003-08-30 04:17:06 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
2003-08-30 05:45:10 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
def __init__(self,name,person_id=None):
|
2004-12-23 06:27:56 +05:30
|
|
|
ReportOptions.ReportOptions.__init__(self,name,person_id)
|
|
|
|
|
|
|
|
def set_new_options(self):
|
2004-12-22 07:26:37 +05:30
|
|
|
# Options specific for this report
|
|
|
|
self.options_dict = {
|
|
|
|
'sortby' : 0,
|
|
|
|
'title' : '',
|
|
|
|
}
|
|
|
|
self.options_help = {
|
|
|
|
'sortby' : ("=num","Number of a sorting function",
|
|
|
|
[item[0] for item in
|
|
|
|
self.get_sort_functions(Sort.Sort(None))],
|
|
|
|
True),
|
|
|
|
'title' : ("=str","Title string for the report",
|
|
|
|
"Whatever String You Wish"),
|
|
|
|
}
|
|
|
|
|
2004-12-23 06:27:56 +05:30
|
|
|
def enable_options(self):
|
2004-12-22 07:26:37 +05:30
|
|
|
# Semi-common options that should be enabled for this report
|
|
|
|
self.enable_dict = {
|
|
|
|
'filter' : 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
def make_default_style(self,default_style):
|
|
|
|
"""Make the default output style for the Timeline report."""
|
|
|
|
f = BaseDoc.FontStyle()
|
|
|
|
f.set_size(10)
|
|
|
|
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
|
|
|
p.set_font(f)
|
|
|
|
p.set_description(_("The style used for the person's name."))
|
|
|
|
default_style.add_style("TLG-Name",p)
|
|
|
|
|
|
|
|
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 style used for the year labels."))
|
|
|
|
default_style.add_style("TLG-Label",p)
|
|
|
|
|
|
|
|
f = BaseDoc.FontStyle()
|
|
|
|
f.set_size(14)
|
|
|
|
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 of the page."))
|
|
|
|
default_style.add_style("TLG-Title",p)
|
|
|
|
|
|
|
|
def get_report_filters(self,person):
|
|
|
|
"""Set up the list of possible content filters."""
|
|
|
|
if person:
|
|
|
|
name = person.get_primary_name().get_name()
|
|
|
|
handle = person.get_handle()
|
|
|
|
else:
|
|
|
|
name = 'PERSON'
|
|
|
|
handle = ''
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
all = GenericFilter.GenericFilter()
|
|
|
|
all.set_name(_("Entire Database"))
|
|
|
|
all.add_rule(GenericFilter.Everyone([]))
|
2003-10-31 06:50:58 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
des = GenericFilter.GenericFilter()
|
|
|
|
des.set_name(_("Descendants of %s") % name)
|
|
|
|
des.add_rule(GenericFilter.IsDescendantOf([handle,1]))
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
ans = GenericFilter.GenericFilter()
|
|
|
|
ans.set_name(_("Ancestors of %s") % name)
|
|
|
|
ans.add_rule(GenericFilter.IsAncestorOf([handle,1]))
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
com = GenericFilter.GenericFilter()
|
|
|
|
com.set_name(_("People with common ancestor with %s") % name)
|
|
|
|
com.add_rule(GenericFilter.HasCommonAncestorWith([handle]))
|
2003-08-30 05:45:10 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
return [all,des,ans,com]
|
2003-04-18 09:45:42 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
def get_sort_functions(self,sort):
|
|
|
|
return [
|
|
|
|
(_("Birth Date"),sort.by_birthdate),
|
|
|
|
(_("Name"),sort.by_last_name),
|
|
|
|
]
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
def add_user_options(self,dialog):
|
2003-02-09 05:15:21 +05:30
|
|
|
"""
|
|
|
|
Override the base class add_user_options task to add a menu that allows
|
|
|
|
the user to select the sort method.
|
|
|
|
"""
|
|
|
|
|
2004-12-28 05:53:49 +05:30
|
|
|
self.sort_menu = gtk.combo_box_new_text()
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
sort_functions = self.get_sort_functions(Sort.Sort(dialog.db))
|
2004-12-28 05:53:49 +05:30
|
|
|
for item in sort_functions:
|
|
|
|
self.sort_menu.append_text(item[0])
|
2003-02-09 05:15:21 +05:30
|
|
|
|
2004-12-28 05:53:49 +05:30
|
|
|
self.sort_menu.set_active(self.options_dict['sortby'])
|
2004-12-22 07:26:37 +05:30
|
|
|
|
2004-12-28 05:53:49 +05:30
|
|
|
dialog.add_option(_('Sort by'),self.sort_menu)
|
2003-02-09 05:15:21 +05:30
|
|
|
|
|
|
|
self.title_box = gtk.Entry()
|
2004-12-22 07:26:37 +05:30
|
|
|
if self.options_dict['title']:
|
|
|
|
self.title_box.set_text(self.options_dict['title'])
|
|
|
|
else:
|
|
|
|
self.title_box.set_text(dialog.get_header(dialog.person.get_primary_name().get_name()))
|
2003-02-09 05:15:21 +05:30
|
|
|
self.title_box.show()
|
2004-12-22 07:26:37 +05:30
|
|
|
dialog.add_option(_('Title'),self.title_box)
|
2003-08-30 04:17:06 +05:30
|
|
|
|
2004-12-22 07:26:37 +05:30
|
|
|
def parse_user_options(self,dialog):
|
2003-08-30 05:45:10 +05:30
|
|
|
"""
|
2004-12-22 07:26:37 +05:30
|
|
|
Parses the custom options that we have added.
|
2003-08-30 05:45:10 +05:30
|
|
|
"""
|
2004-12-22 07:26:37 +05:30
|
|
|
self.options_dict['title'] = unicode(self.title_box.get_text())
|
2004-12-28 05:53:49 +05:30
|
|
|
self.options_dict['sortby'] = self.sort_menu.get_active()
|
2003-08-30 05:45:10 +05:30
|
|
|
|
2003-08-30 04:17:06 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2004-12-22 07:26:37 +05:30
|
|
|
from Plugins import register_report
|
2003-02-09 05:15:21 +05:30
|
|
|
register_report(
|
2004-12-22 07:26:37 +05:30
|
|
|
name = 'timeline',
|
|
|
|
category = const.CATEGORY_DRAW,
|
|
|
|
report_class = TimeLine,
|
|
|
|
options_class = TimeLineOptions,
|
|
|
|
modes = Report.MODE_GUI | Report.MODE_BKI | Report.MODE_CLI,
|
|
|
|
translated_name = _("Timeline Graph"),
|
|
|
|
status = _("Beta"),
|
|
|
|
author_name = "Donald N. Allingham",
|
|
|
|
author_email = "dallingham@users.sourceforge.net",
|
|
|
|
description = _("Generates a timeline graph.")
|
2003-08-30 04:17:06 +05:30
|
|
|
)
|