diff --git a/src/plugins/drawreport/AncestorTree.py b/src/plugins/drawreport/AncestorTree.py index 946b8efa7..f071d146a 100644 --- a/src/plugins/drawreport/AncestorTree.py +++ b/src/plugins/drawreport/AncestorTree.py @@ -669,6 +669,18 @@ class AncestorTree2(Report): person - currently selected person 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) 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. indblank - Whether to include blank pages. 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')) - - self.connect = GUIConnect() - self.connect.set__opts(options_class.menu) + database = self.database + #Set up the canvas that we will print on. style_sheet = self.doc.get_style_sheet() font_normal = style_sheet.get_paragraph_style("AC2-Normal").get_font() 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) - #make the tree into self.canvas + #make the tree onto the canvas inlc_marr = self.connect.get_val('incmarr') self.max_generations = self.connect.get_val('maxgen') fillout = self.connect.get_val('fillout') @@ -721,17 +735,9 @@ class AncestorTree2(Report): self.max_generations = report.get_generations() #already know 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() + #Note? if self.connect.get_val('use_note'): note_box = NoteBox(self.doc, "AC2-fam-box", self.connect.get_val('note_local')) @@ -740,6 +746,8 @@ class AncestorTree2(Report): self.connect.get_val('note_disp')) 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') scale_report = self.connect.get_val('scale_report') diff --git a/src/plugins/drawreport/DescendTree.py b/src/plugins/drawreport/DescendTree.py index 6146ab3e1..5e5bb3a83 100644 --- a/src/plugins/drawreport/DescendTree.py +++ b/src/plugins/drawreport/DescendTree.py @@ -1267,21 +1267,28 @@ class Descend2Tree(Report): database - the GRAMPS database instance 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) + + self.database = database self.Connect = GuiConnect() 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() font_normal = style_sheet.get_paragraph_style("CG2-Normal").get_font() self.doc.report_opts = ReportOptions(self.doc, font_normal, "CG2-line") - self.canvas = Canvas(self.doc) - center_id = self.Connect.get_val('pid') #make the tree @@ -1300,12 +1307,8 @@ class Descend2Tree(Report): report = MakeReport(database, self.canvas, ind_spouse, compress_tree) report.start() report = None - - def begin_report(self): - """ We have a report in its full size and pages to print on - scale one or both as needed/desired. - """ - + + #note? if self.Connect.get_val('use_note'): note_box = NoteBox(self.doc, "CG2-fam-box", self.Connect.get_val('note_local')) @@ -1314,6 +1317,8 @@ class Descend2Tree(Report): self.Connect.get_val('note_disp')) 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') scale_report = self.Connect.get_val('scale_report') diff --git a/src/plugins/lib/libtreebase.py b/src/plugins/lib/libtreebase.py index 800214e00..60ffd6532 100644 --- a/src/plugins/lib/libtreebase.py +++ b/src/plugins/lib/libtreebase.py @@ -89,9 +89,9 @@ class Page(object): Offsets from the canvas, Page numbers boxes and lines """ - def __init__(self, doc, canvas): + def __init__(self, canvas): #parts from canvas - self.doc = doc + #self.doc = doc self.canvas = canvas #parts about the page @@ -117,21 +117,22 @@ class Page(object): self.lines.append(line) def draw_border(self, line_name): + doc = self.canvas.doc if self.y_page_num == 0: - self.doc.draw_line(line_name, 0, 0, - self.doc.get_usable_width(), 0) + doc.draw_line(line_name, 0, 0, + doc.get_usable_width(), 0) if self.x_page_num == 0: - self.doc.draw_line(line_name, 0, 0, 0, - self.doc.get_usable_height()) + doc.draw_line(line_name, 0, 0, 0, + doc.get_usable_height()) if self.y_page_num == self.canvas.y_pages-1: - self.doc.draw_line(line_name, 0, - self.doc.get_usable_height(), - self.doc.get_usable_width(), - self.doc.get_usable_height()) + doc.draw_line(line_name, 0, + doc.get_usable_height(), + doc.get_usable_width(), + doc.get_usable_height()) if self.x_page_num == self.canvas.x_pages-1: - self.doc.draw_line(line_name, self.doc.get_usable_width(), - 0, self.doc.get_usable_width(), - self.doc.get_usable_height()) + doc.draw_line(line_name, doc.get_usable_width(), + 0, doc.get_usable_width(), + doc.get_usable_height()) def display(self): """ 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 """ def __init__(self, doc): - Page.__init__(self, doc, self) + Page.__init__(self, self) self.doc = doc self.report_opts = None @@ -165,7 +166,7 @@ class Canvas(Page): paginating (making new pages to hold parts of the canvas) """ if x_page >= self.x_pages: 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.y_page_num = y_page new_page.page_x_offset = x_offset @@ -261,7 +262,7 @@ class Canvas(Page): def page_iter_gen(self, incblank): """ generate the pages of the report. do so in a left to right 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 x_p in range(self.x_pages): if self.__pages.has_key((x_p, y_p)): @@ -591,11 +592,12 @@ class BoxBase(object): if self.boxstr == "None": return + doc = self.page.canvas.doc text = '\n'.join(self.text) xbegin = self.x_cm - self.page.page_x_offset ybegin = self.y_cm - self.page.page_y_offset - self.page.doc.draw_box(self.boxstr, + doc.draw_box(self.boxstr, text, xbegin, ybegin, self.width, self.height) @@ -605,11 +607,10 @@ class BoxBase(object): #draw my line out here. self.line_to.display(self.page) 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 yme = ybegin + self.height/2 - self.page.doc.draw_line(self.page.doc.report_opts.line_str, \ - 0, yme, xbegin, yme) + doc.draw_line(doc.report_opts.line_str, 0, yme, xbegin, yme) @@ -813,7 +814,7 @@ class LineBase(object): #if type(self.start) != type([]): # self.start = [self.start] start = self.start[0] - doc = start.page.doc + doc = start.page.canvas.doc linestr = doc.report_opts.line_str xbegin = start.x_cm + start.width - page.page_x_offset