* src/plugins/FanChart.py: Convert to new scheme.

* src/SubstKeywords.py (SubstKeywords.__init__): Typo.
* src/plugins/TimeLine.py: Remove unneeded imports.
* src/plugins/FamilyGroup.py: Remove unneeded imports.
* src/plugins/Ancestors.py: Remove unneeded imports.


svn: r3857
This commit is contained in:
Alex Roitman 2005-01-02 06:40:08 +00:00
parent f4f8bc672d
commit 315b674d84
6 changed files with 93 additions and 258 deletions

View File

@ -11,6 +11,12 @@
* src/plugins/FamilyGroup.py: Convert to new scheme. * src/plugins/FamilyGroup.py: Convert to new scheme.
* src/Report.py: Typos. * src/Report.py: Typos.
* src/plugins/FanChart.py: Convert to new scheme.
* src/SubstKeywords.py (SubstKeywords.__init__): Typo.
* src/plugins/TimeLine.py: Remove unneeded imports.
* src/plugins/FamilyGroup.py: Remove unneeded imports.
* src/plugins/Ancestors.py: Remove unneeded imports.
2004-12-31 Don Allingham <dallingham@users.sourceforge.net> 2004-12-31 Don Allingham <dallingham@users.sourceforge.net>
* src/gramps.glade: remove name display options * src/gramps.glade: remove name display options
* src/GrampsCfg.py: remove name displaying functions * src/GrampsCfg.py: remove name displaying functions

View File

@ -107,7 +107,7 @@ class SubstKeywords:
if mother_handle: if mother_handle:
mother = database.get_person_from_handle(mother_handle) mother = database.get_person_from_handle(mother_handle)
self.s = NameDisplay.displayer.display(mother) self.s = NameDisplay.displayer.display(mother)
self.S = NameDIsplay.displayer.sorted(mother) self.S = NameDisplay.displayer.sorted(mother)
else: else:
if father_handle: if father_handle:
father = database.get_person_from_handle(father_handle) father = database.get_person_from_handle(father_handle)

View File

@ -44,9 +44,7 @@ import const
import Report import Report
import BaseDoc import BaseDoc
import RelLib import RelLib
import Errors
import Plugins import Plugins
from QuestionDialog import ErrorDialog
import ReportOptions import ReportOptions
from DateHandler import displayer as _dd from DateHandler import displayer as _dd
@ -83,9 +81,6 @@ class ComprehensiveAncestorsReport (Report.Report):
= options_class.get_report_generations() = options_class.get_report_generations()
self.opt_cite = options_class.handler.options_dict['cites'] self.opt_cite = options_class.handler.options_dict['cites']
self.output = options_class.get_output()
self.newpage = options_class.get_newpage()
self.sources = [] self.sources = []
self.sourcerefs = [] self.sourcerefs = []
self.RelClass = Plugins.relationship_class self.RelClass = Plugins.relationship_class
@ -988,7 +983,6 @@ class ComprehensiveAncestorsOptions(ReportOptions.ReportOptions):
""" """
self.options_dict['cites'] = int(self.cb_cite.get_active ()) self.options_dict['cites'] = int(self.cb_cite.get_active ())
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# #

View File

@ -44,9 +44,6 @@ import gtk
import RelLib import RelLib
import Report import Report
import BaseDoc import BaseDoc
import Errors
import Utils
from QuestionDialog import ErrorDialog
import ReportOptions import ReportOptions
import const import const
from DateHandler import displayer as _dd from DateHandler import displayer as _dd

View File

@ -20,6 +20,13 @@
# $Id$ # $Id$
#------------------------------------------------------------------------
#
# python modules
#
#------------------------------------------------------------------------
from gettext import gettext as _
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# gnome/gtk # gnome/gtk
@ -34,47 +41,46 @@ import gtk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import BaseDoc import BaseDoc
import Report import Report
import Errors import ReportOptions
import Date import const
from QuestionDialog import ErrorDialog
from SubstKeywords import SubstKeywords from SubstKeywords import SubstKeywords
from gettext import gettext as _ from Utils import pt2cm
#------------------------------------------------------------------------
#
# pt2cm - convert points to centimeters
#
#------------------------------------------------------------------------
def pt2cm(pt):
return (float(pt)/72.0)*(254.0/100.0)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# FanChart # FanChart
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class FanChart: class FanChart(Report.Report):
def __init__(self,database,person,options_class):
#database,person,display,doc,output,newpage=0):
"""
Creates the FanChart 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.
display -
"""
Report.Report.__init__(self,database,person,options_class)
def __init__(self,database,person,display,doc,output,newpage=0):
self.database = database
self.doc = doc
self.doc.creator(database.get_researcher().get_name())
self.map = {}
self.text = {}
self.start = person
self.output = output
self.box_width = 0
self.height = 0 self.height = 0
self.lines = 0 self.lines = 0
self.display = display self.display = "%n"
self.newpage = newpage self.map = [None] * 32
if output: self.text= {}
self.standalone = 1 self.box_width = 0
self.doc.open(output)
else:
self.standalone = 0
self.setup()
def setup(self):
g = BaseDoc.GraphicsStyle() g = BaseDoc.GraphicsStyle()
g.set_paragraph_style('FC-Title') g.set_paragraph_style('FC-Title')
g.set_line_width(0) g.set_line_width(0)
@ -135,13 +141,7 @@ class FanChart:
g.set_line_width(0) g.set_line_width(0)
self.doc.add_draw_style("FC-c5n",g) self.doc.add_draw_style("FC-c5n",g)
self.map = [None] * 32 def apply_filter(self,person_handle,index):
self.text= {}
self.box_width = 0
if self.standalone:
self.doc.init()
def filter(self,person_handle,index):
"""traverse the ancestors recursively until either the end """traverse the ancestors recursively until either the end
of a line is found, or until we reach the maximum number of of a line is found, or until we reach the maximum number of
generations that we want to deal with""" generations that we want to deal with"""
@ -167,18 +167,15 @@ class FanChart:
family_handle = person.get_main_parents_family_handle() family_handle = person.get_main_parents_family_handle()
if family_handle: if family_handle:
family = self.database.get_family_from_handle(family_handle) family = self.database.get_family_from_handle(family_handle)
self.filter(family.get_father_handle(),index*2) self.apply_filter(family.get_father_handle(),index*2)
self.filter(family.get_mother_handle(),(index*2)+1) self.apply_filter(family.get_mother_handle(),(index*2)+1)
def write_report(self): def write_report(self):
self.filter(self.start.get_handle(),1) self.apply_filter(self.start_person.get_handle(),1)
block_size = self.doc.get_usable_width()/14.0 block_size = self.doc.get_usable_width()/14.0
if self.newpage:
self.doc.page_break()
size = min(self.doc.get_usable_width(),self.doc.get_usable_height()*2.0)/2.0 size = min(self.doc.get_usable_width(),self.doc.get_usable_height()*2.0)/2.0
y = self.doc.get_usable_height() y = self.doc.get_usable_height()
max_lines = int(size/block_size) max_lines = int(size/block_size)
@ -186,7 +183,7 @@ class FanChart:
self.doc.start_page() self.doc.start_page()
n = self.start.get_primary_name().get_regular_name() n = self.start_person.get_primary_name().get_regular_name()
self.doc.center_text('t', _('Five Generation Fan Chart for %s') % n, center, 0) self.doc.center_text('t', _('Five Generation Fan Chart for %s') % n, center, 0)
self.circle_5(center,y,block_size) self.circle_5(center,y,block_size)
@ -196,8 +193,6 @@ class FanChart:
self.circle_1(center,y,block_size) self.circle_1(center,y,block_size)
self.doc.end_page() self.doc.end_page()
if self.standalone:
self.doc.close()
def get_info(self,person_handle): def get_info(self,person_handle):
person = self.database.get_person_from_handle(person_handle) person = self.database.get_person_from_handle(person_handle)
@ -286,206 +281,52 @@ class FanChart:
# #
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
def _make_default_style(default_style): class FanChartOptions(ReportOptions.ReportOptions):
"""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) Defines options and provides handling interface.
f.set_bold(1) """
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
p = BaseDoc.ParagraphStyle() def __init__(self,name,person_id=None):
p.set_font(f) ReportOptions.ReportOptions.__init__(self,name,person_id)
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_description(_('The style used for the title.'))
default_style.add_style("FC-Title",p) def make_default_style(self,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)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# FanChartDialog #
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class FanChartDialog(Report.DrawReportDialog): from Plugins import register_report
report_options = {}
def __init__(self,database,person):
Report.DrawReportDialog.__init__(self,database,person,self.report_options)
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."""
return _style_file
def get_report_generations(self):
"""Default to 10 generations, no page breaks."""
return (0, 0)
def make_default_style(self):
_make_default_style(self.default_style)
def make_report(self):
"""Create the object that will produce the Fan Chart.
All user dialog has already been handled and the output file
opened."""
try:
MyReport = FanChart(self.db, self.person,
"%n", self.doc, self.target_path)
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)
#------------------------------------------------------------------------
#
# Set up sane defaults for the book_item
#
#------------------------------------------------------------------------
_style_file = "fan_chart.xml"
_style_name = "default"
_person_handle = ""
_options = ( _person_handle, )
#------------------------------------------------------------------------
#
# 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]:
self.person = self.db.get_person_from_handle(self.options[0])
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
self.options = ( self.person.get_handle(), )
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]:
person = database.get_person_from_handle(options[0])
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()
#------------------------------------------------------------------------
#
# Register the report with the plugin system. If this is not done, then
# GRAMPS will not know that the report exists.
#
#------------------------------------------------------------------------
from Plugins import register_report, register_book_item
register_report( register_report(
report, name = 'fan_chart',
_("Fan Chart"), category = const.CATEGORY_DRAW,
category=_("Graphical Reports"), report_class = FanChart,
status=(_("Alpha")), options_class = FanChartOptions,
description=_("Produces a five generation fan chart") modes = Report.MODE_GUI | Report.MODE_BKI | Report.MODE_CLI,
) translated_name = _("Fan Chart"),
status = _("Alpha"),
# (name,category,options_dialog,write_book_item,options,style_name,style_file,make_default_style) author_name = "Donald N. Allingham",
register_book_item( author_email = "dallingham@users.sourceforge.net",
_("Fan Chart"), description = _("Produces a five generation fan chart")
_("Graphics"),
FanChartBareDialog,
write_book_item,
_options,
_style_name,
_style_file,
_make_default_style
) )

View File

@ -29,7 +29,6 @@ Timeline report
# python modules # python modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import os
from gettext import gettext as _ from gettext import gettext as _
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -44,12 +43,10 @@ import gtk
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import Utils from Utils import pt2cm
import Report import Report
import BaseDoc import BaseDoc
import GenericFilter import GenericFilter
import Errors
import Date
import Sort import Sort
import ReportOptions import ReportOptions
from QuestionDialog import ErrorDialog from QuestionDialog import ErrorDialog
@ -178,7 +175,7 @@ class TimeLine(Report.Report):
font = self.doc.style_list['TLG-Name'].get_font() font = self.doc.style_list['TLG-Name'].get_font()
incr = Utils.pt2cm(font.get_size()) incr = pt2cm(font.get_size())
pad = incr*.75 pad = incr*.75
x1,x2,y1,y2 = (0,0,0,0) x1,x2,y1,y2 = (0,0,0,0)
@ -273,7 +270,7 @@ class TimeLine(Report.Report):
self.doc.center_text('TLG-title',self.title,width/2.0,0) self.doc.center_text('TLG-title',self.title,width/2.0,0)
label_y = self.header - (Utils.pt2cm(normal_font.get_size())*1.2) label_y = self.header - (pt2cm(normal_font.get_size())*1.2)
top_y = self.header top_y = self.header
bottom_y = self.doc.get_usable_height() bottom_y = self.doc.get_usable_height()
@ -338,7 +335,7 @@ class TimeLine(Report.Report):
p = self.database.get_person_from_handle(p_id) p = self.database.get_person_from_handle(p_id)
n = p.get_primary_name().get_name() n = p.get_primary_name().get_name()
size = max(self.doc.string_width(font,n),size) size = max(self.doc.string_width(font,n),size)
return Utils.pt2cm(size) return pt2cm(size)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #