Fixes (part one) for
http://www.gramps-project.org/bugs/view.php?id=4727 too much report work was done in __init__() Moved it to begin_report() also modified libtreebase to not have so many pointers to .doc svn: r16777
This commit is contained in:
parent
20fb30aaba
commit
ed32530f57
@ -669,6 +669,18 @@ class AncestorTree2(Report):
|
|||||||
person - currently selected person
|
person - currently selected person
|
||||||
options_class - instance of the Options class for this report
|
options_class - instance of the Options class for this report
|
||||||
|
|
||||||
|
"""
|
||||||
|
Report.__init__(self, database, options_class)
|
||||||
|
self.database = database
|
||||||
|
|
||||||
|
self.connect = GUIConnect()
|
||||||
|
self.connect.set__opts(options_class.menu)
|
||||||
|
|
||||||
|
#The canvas that we will put our report on and print off of
|
||||||
|
self.canvas = Canvas(self.doc)
|
||||||
|
|
||||||
|
def begin_report(self):
|
||||||
|
"""
|
||||||
This report needs the following parameters (class variables)
|
This report needs the following parameters (class variables)
|
||||||
that come in the options class.
|
that come in the options class.
|
||||||
|
|
||||||
@ -678,23 +690,25 @@ class AncestorTree2(Report):
|
|||||||
scale_report - Whether to scale the report to fit the width or all.
|
scale_report - Whether to scale the report to fit the width or all.
|
||||||
indblank - Whether to include blank pages.
|
indblank - Whether to include blank pages.
|
||||||
compress - Whether to compress chart.
|
compress - Whether to compress chart.
|
||||||
|
|
||||||
|
We will
|
||||||
|
1. a canvas in its full one-page size
|
||||||
|
2. a page that we wish to print on
|
||||||
|
scale up/down either or both of the above as needed/desired.
|
||||||
|
almost all of this should be moved into Canvas!
|
||||||
"""
|
"""
|
||||||
Report.__init__(self, database, options_class)
|
|
||||||
|
|
||||||
self.progress = ProgressMeter(_('Ancestor Tree'))
|
database = self.database
|
||||||
|
|
||||||
self.connect = GUIConnect()
|
|
||||||
self.connect.set__opts(options_class.menu)
|
|
||||||
|
|
||||||
|
#Set up the canvas that we will print on.
|
||||||
style_sheet = self.doc.get_style_sheet()
|
style_sheet = self.doc.get_style_sheet()
|
||||||
font_normal = style_sheet.get_paragraph_style("AC2-Normal").get_font()
|
font_normal = style_sheet.get_paragraph_style("AC2-Normal").get_font()
|
||||||
self.doc.report_opts = ReportOptions(self.doc, font_normal, 'AC2-line')
|
self.doc.report_opts = ReportOptions(self.doc, font_normal, 'AC2-line')
|
||||||
|
|
||||||
self.canvas = Canvas(self.doc)
|
self.progress = ProgressMeter(_('Ancestor Tree'))
|
||||||
|
|
||||||
self.progress.set_pass(_('Making the Tree...'), 4)
|
self.progress.set_pass(_('Making the Tree...'), 4)
|
||||||
|
|
||||||
#make the tree into self.canvas
|
#make the tree onto the canvas
|
||||||
inlc_marr = self.connect.get_val('incmarr')
|
inlc_marr = self.connect.get_val('incmarr')
|
||||||
self.max_generations = self.connect.get_val('maxgen')
|
self.max_generations = self.connect.get_val('maxgen')
|
||||||
fillout = self.connect.get_val('fillout')
|
fillout = self.connect.get_val('fillout')
|
||||||
@ -721,17 +735,9 @@ class AncestorTree2(Report):
|
|||||||
self.max_generations = report.get_generations() #already know
|
self.max_generations = report.get_generations() #already know
|
||||||
report = None
|
report = None
|
||||||
|
|
||||||
def begin_report(self):
|
|
||||||
"""
|
|
||||||
We have
|
|
||||||
1. a canvas in its full one-page size
|
|
||||||
2. a page that we wish to print on
|
|
||||||
scale up/down either or both of the above as needed/desired.
|
|
||||||
almost all of this should be moved into Canvas!
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.progress.step()
|
self.progress.step()
|
||||||
|
|
||||||
|
#Note?
|
||||||
if self.connect.get_val('use_note'):
|
if self.connect.get_val('use_note'):
|
||||||
note_box = NoteBox(self.doc, "AC2-fam-box",
|
note_box = NoteBox(self.doc, "AC2-fam-box",
|
||||||
self.connect.get_val('note_local'))
|
self.connect.get_val('note_local'))
|
||||||
@ -740,6 +746,8 @@ class AncestorTree2(Report):
|
|||||||
self.connect.get_val('note_disp'))
|
self.connect.get_val('note_disp'))
|
||||||
self.canvas.add_note(note_box)
|
self.canvas.add_note(note_box)
|
||||||
|
|
||||||
|
#Now we have the report in its full size.
|
||||||
|
#Do we want to scale the report?
|
||||||
one_page = self.connect.get_val('onepage')
|
one_page = self.connect.get_val('onepage')
|
||||||
scale_report = self.connect.get_val('scale_report')
|
scale_report = self.connect.get_val('scale_report')
|
||||||
|
|
||||||
|
@ -1267,21 +1267,28 @@ class Descend2Tree(Report):
|
|||||||
|
|
||||||
database - the GRAMPS database instance
|
database - the GRAMPS database instance
|
||||||
options_class - instance of the Options class for this report
|
options_class - instance of the Options class for this report
|
||||||
|
|
||||||
This report needs the following parameters (class variables)
|
|
||||||
that come in the options class.
|
|
||||||
"""
|
"""
|
||||||
Report.__init__(self, database, options_class)
|
Report.__init__(self, database, options_class)
|
||||||
|
|
||||||
|
self.database = database
|
||||||
|
|
||||||
self.Connect = GuiConnect()
|
self.Connect = GuiConnect()
|
||||||
self.Connect.set__opts(options_class.menu, options_class.name)
|
self.Connect.set__opts(options_class.menu, options_class.name)
|
||||||
|
|
||||||
|
#The canvas that we will put our report on and print off of
|
||||||
|
self.canvas = Canvas(self.doc)
|
||||||
|
|
||||||
|
def begin_report(self):
|
||||||
|
""" make the report in its full size and pages to print on
|
||||||
|
scale one or both as needed/desired.
|
||||||
|
"""
|
||||||
|
|
||||||
|
database = self.database
|
||||||
|
|
||||||
style_sheet = self.doc.get_style_sheet()
|
style_sheet = self.doc.get_style_sheet()
|
||||||
font_normal = style_sheet.get_paragraph_style("CG2-Normal").get_font()
|
font_normal = style_sheet.get_paragraph_style("CG2-Normal").get_font()
|
||||||
self.doc.report_opts = ReportOptions(self.doc, font_normal, "CG2-line")
|
self.doc.report_opts = ReportOptions(self.doc, font_normal, "CG2-line")
|
||||||
|
|
||||||
self.canvas = Canvas(self.doc)
|
|
||||||
|
|
||||||
center_id = self.Connect.get_val('pid')
|
center_id = self.Connect.get_val('pid')
|
||||||
|
|
||||||
#make the tree
|
#make the tree
|
||||||
@ -1301,11 +1308,7 @@ class Descend2Tree(Report):
|
|||||||
report.start()
|
report.start()
|
||||||
report = None
|
report = None
|
||||||
|
|
||||||
def begin_report(self):
|
#note?
|
||||||
""" We have a report in its full size and pages to print on
|
|
||||||
scale one or both as needed/desired.
|
|
||||||
"""
|
|
||||||
|
|
||||||
if self.Connect.get_val('use_note'):
|
if self.Connect.get_val('use_note'):
|
||||||
note_box = NoteBox(self.doc, "CG2-fam-box",
|
note_box = NoteBox(self.doc, "CG2-fam-box",
|
||||||
self.Connect.get_val('note_local'))
|
self.Connect.get_val('note_local'))
|
||||||
@ -1314,6 +1317,8 @@ class Descend2Tree(Report):
|
|||||||
self.Connect.get_val('note_disp'))
|
self.Connect.get_val('note_disp'))
|
||||||
self.canvas.add_note(note_box)
|
self.canvas.add_note(note_box)
|
||||||
|
|
||||||
|
#Now we have the report in its full size.
|
||||||
|
#Do we want to scale the report?
|
||||||
one_page = self.Connect.get_val('onepage')
|
one_page = self.Connect.get_val('onepage')
|
||||||
scale_report = self.Connect.get_val('scale_report')
|
scale_report = self.Connect.get_val('scale_report')
|
||||||
|
|
||||||
|
@ -89,9 +89,9 @@ class Page(object):
|
|||||||
Offsets from the canvas, Page numbers
|
Offsets from the canvas, Page numbers
|
||||||
boxes and lines
|
boxes and lines
|
||||||
"""
|
"""
|
||||||
def __init__(self, doc, canvas):
|
def __init__(self, canvas):
|
||||||
#parts from canvas
|
#parts from canvas
|
||||||
self.doc = doc
|
#self.doc = doc
|
||||||
self.canvas = canvas
|
self.canvas = canvas
|
||||||
|
|
||||||
#parts about the page
|
#parts about the page
|
||||||
@ -117,21 +117,22 @@ class Page(object):
|
|||||||
self.lines.append(line)
|
self.lines.append(line)
|
||||||
|
|
||||||
def draw_border(self, line_name):
|
def draw_border(self, line_name):
|
||||||
|
doc = self.canvas.doc
|
||||||
if self.y_page_num == 0:
|
if self.y_page_num == 0:
|
||||||
self.doc.draw_line(line_name, 0, 0,
|
doc.draw_line(line_name, 0, 0,
|
||||||
self.doc.get_usable_width(), 0)
|
doc.get_usable_width(), 0)
|
||||||
if self.x_page_num == 0:
|
if self.x_page_num == 0:
|
||||||
self.doc.draw_line(line_name, 0, 0, 0,
|
doc.draw_line(line_name, 0, 0, 0,
|
||||||
self.doc.get_usable_height())
|
doc.get_usable_height())
|
||||||
if self.y_page_num == self.canvas.y_pages-1:
|
if self.y_page_num == self.canvas.y_pages-1:
|
||||||
self.doc.draw_line(line_name, 0,
|
doc.draw_line(line_name, 0,
|
||||||
self.doc.get_usable_height(),
|
doc.get_usable_height(),
|
||||||
self.doc.get_usable_width(),
|
doc.get_usable_width(),
|
||||||
self.doc.get_usable_height())
|
doc.get_usable_height())
|
||||||
if self.x_page_num == self.canvas.x_pages-1:
|
if self.x_page_num == self.canvas.x_pages-1:
|
||||||
self.doc.draw_line(line_name, self.doc.get_usable_width(),
|
doc.draw_line(line_name, doc.get_usable_width(),
|
||||||
0, self.doc.get_usable_width(),
|
0, doc.get_usable_width(),
|
||||||
self.doc.get_usable_height())
|
doc.get_usable_height())
|
||||||
|
|
||||||
def display(self):
|
def display(self):
|
||||||
""" Display all boxes and lines that are on this page """
|
""" Display all boxes and lines that are on this page """
|
||||||
@ -148,7 +149,7 @@ class Canvas(Page):
|
|||||||
part of what is on the entire canvas
|
part of what is on the entire canvas
|
||||||
"""
|
"""
|
||||||
def __init__(self, doc):
|
def __init__(self, doc):
|
||||||
Page.__init__(self, doc, self)
|
Page.__init__(self, self)
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
self.report_opts = None
|
self.report_opts = None
|
||||||
|
|
||||||
@ -165,7 +166,7 @@ class Canvas(Page):
|
|||||||
paginating (making new pages to hold parts of the canvas) """
|
paginating (making new pages to hold parts of the canvas) """
|
||||||
if x_page >= self.x_pages:
|
if x_page >= self.x_pages:
|
||||||
self.x_pages = x_page + 1
|
self.x_pages = x_page + 1
|
||||||
new_page = Page(self.doc, self)
|
new_page = Page(self)
|
||||||
new_page.x_page_num = x_page
|
new_page.x_page_num = x_page
|
||||||
new_page.y_page_num = y_page
|
new_page.y_page_num = y_page
|
||||||
new_page.page_x_offset = x_offset
|
new_page.page_x_offset = x_offset
|
||||||
@ -261,7 +262,7 @@ class Canvas(Page):
|
|||||||
def page_iter_gen(self, incblank):
|
def page_iter_gen(self, incblank):
|
||||||
""" generate the pages of the report. do so in a left to right
|
""" generate the pages of the report. do so in a left to right
|
||||||
up down approach. incblank asks to include blank pages """
|
up down approach. incblank asks to include blank pages """
|
||||||
blank = Page(self.doc, self)
|
blank = Page(self)
|
||||||
for y_p in range(self.y_pages):
|
for y_p in range(self.y_pages):
|
||||||
for x_p in range(self.x_pages):
|
for x_p in range(self.x_pages):
|
||||||
if self.__pages.has_key((x_p, y_p)):
|
if self.__pages.has_key((x_p, y_p)):
|
||||||
@ -591,11 +592,12 @@ class BoxBase(object):
|
|||||||
if self.boxstr == "None":
|
if self.boxstr == "None":
|
||||||
return
|
return
|
||||||
|
|
||||||
|
doc = self.page.canvas.doc
|
||||||
text = '\n'.join(self.text)
|
text = '\n'.join(self.text)
|
||||||
xbegin = self.x_cm - self.page.page_x_offset
|
xbegin = self.x_cm - self.page.page_x_offset
|
||||||
ybegin = self.y_cm - self.page.page_y_offset
|
ybegin = self.y_cm - self.page.page_y_offset
|
||||||
|
|
||||||
self.page.doc.draw_box(self.boxstr,
|
doc.draw_box(self.boxstr,
|
||||||
text,
|
text,
|
||||||
xbegin, ybegin,
|
xbegin, ybegin,
|
||||||
self.width, self.height)
|
self.width, self.height)
|
||||||
@ -605,11 +607,10 @@ class BoxBase(object):
|
|||||||
#draw my line out here.
|
#draw my line out here.
|
||||||
self.line_to.display(self.page)
|
self.line_to.display(self.page)
|
||||||
if self.page.x_page_num > 0 and self.level[1] == 0 and \
|
if self.page.x_page_num > 0 and self.level[1] == 0 and \
|
||||||
xbegin < self.page.doc.report_opts.littleoffset*2:
|
xbegin < doc.report_opts.littleoffset*2:
|
||||||
#I am a child on the first column
|
#I am a child on the first column
|
||||||
yme = ybegin + self.height/2
|
yme = ybegin + self.height/2
|
||||||
self.page.doc.draw_line(self.page.doc.report_opts.line_str, \
|
doc.draw_line(doc.report_opts.line_str, 0, yme, xbegin, yme)
|
||||||
0, yme, xbegin, yme)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -813,7 +814,7 @@ class LineBase(object):
|
|||||||
#if type(self.start) != type([]):
|
#if type(self.start) != type([]):
|
||||||
# self.start = [self.start]
|
# self.start = [self.start]
|
||||||
start = self.start[0]
|
start = self.start[0]
|
||||||
doc = start.page.doc
|
doc = start.page.canvas.doc
|
||||||
linestr = doc.report_opts.line_str
|
linestr = doc.report_opts.line_str
|
||||||
|
|
||||||
xbegin = start.x_cm + start.width - page.page_x_offset
|
xbegin = start.x_cm + start.width - page.page_x_offset
|
||||||
|
Loading…
x
Reference in New Issue
Block a user