small error fixes to these reports when run in a book report

svn: r19934
This commit is contained in:
Craig J. Anderson 2012-06-28 15:42:16 +00:00
parent b913cde440
commit 508aefea03
3 changed files with 74 additions and 70 deletions

View File

@ -489,9 +489,9 @@ class RLTransform():
""" """
setup all of the boxes on the canvas in for a left/right report setup all of the boxes on the canvas in for a left/right report
""" """
def __init__(self, canvas, opts, max_generations, compress_tree): def __init__(self, canvas, max_generations, compress_tree):
self.canvas = canvas self.canvas = canvas
self.rept_opts = opts self.rept_opts = canvas.report_opts
self.max_generations = max_generations self.max_generations = max_generations
self.compress_tree = compress_tree self.compress_tree = compress_tree
self.y_offset = self.rept_opts.littleoffset*2 + self.canvas.title.height self.y_offset = self.rept_opts.littleoffset*2 + self.canvas.title.height
@ -564,8 +564,8 @@ class MakeReport():
self.canvas.set_box_height_width(box) self.canvas.set_box_height_width(box)
if box.width > self.doc.report_opts.max_box_width: if box.width > self.canvas.report_opts.max_box_width:
self.doc.report_opts.max_box_width = box.width #+ box.shadow self.canvas.report_opts.max_box_width = box.width #+ box.shadow
if box.level[2] > 0: if box.level[2] > 0:
if box.level[2] % 2 == 0 and box.height > self.father_ht: if box.level[2] % 2 == 0 and box.height > self.father_ht:
@ -589,10 +589,10 @@ class MakeReport():
self.get_height_width(box) self.get_height_width(box)
if self.compress_tree and not self.inlc_marr: if self.compress_tree and not self.inlc_marr:
self.doc.report_opts.max_box_height = \ self.canvas.report_opts.max_box_height = \
min(self.father_ht, self.mother_ht) min(self.father_ht, self.mother_ht)
else: else:
self.doc.report_opts.max_box_height = \ self.canvas.report_opts.max_box_height = \
max(self.father_ht, self.mother_ht) max(self.father_ht, self.mother_ht)
#At this point we know everything we need to make the report. #At this point we know everything we need to make the report.
@ -601,11 +601,11 @@ class MakeReport():
#size of each row - self.rept_opt.box_height #size of each row - self.rept_opt.box_height
#go ahead and set it now. #go ahead and set it now.
for box in self.canvas.boxes: for box in self.canvas.boxes:
box.width = self.doc.report_opts.max_box_width box.width = self.canvas.report_opts.max_box_width
# 2. # 2.
#setup the transform class to move around the boxes on the canvas #setup the transform class to move around the boxes on the canvas
transform = RLTransform(self.canvas, self.doc.report_opts, transform = RLTransform(self.canvas,
self.max_generations, self.compress_tree) self.max_generations, self.compress_tree)
transform.place() transform.place()
@ -662,9 +662,6 @@ class AncestorTree(Report):
self.database = database self.database = database
self._user = user self._user = user
#The canvas that we will put our report on and print off of
self.canvas = Canvas(self.doc)
""" """
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.
@ -691,11 +688,15 @@ class AncestorTree(Report):
#Set up the canvas that we will print on. #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')
#The canvas that we will put our report on and print off of
self.canvas = Canvas(self.doc,
ReportOptions(self.doc, font_normal, 'AC2-line'))
self.doc.report_opts.box_shadow *= self.connect.get_val('shadowscale') self.canvas.report_opts.box_shadow *= \
self.doc.report_opts.box_pgap *= self.connect.get_val('box_Yscale') self.connect.get_val('shadowscale')
self.doc.report_opts.box_mgap *= self.connect.get_val('box_Yscale') self.canvas.report_opts.box_pgap *= self.connect.get_val('box_Yscale')
self.canvas.report_opts.box_mgap *= self.connect.get_val('box_Yscale')
self._user.begin_progress(_('Ancestor Tree'), self._user.begin_progress(_('Ancestor Tree'),
_('Making the Tree...'), 4) _('Making the Tree...'), 4)
@ -763,9 +764,9 @@ class AncestorTree(Report):
#Setup page information #Setup page information
colsperpage = self.doc.get_usable_width() colsperpage = self.doc.get_usable_width()
colsperpage += self.doc.report_opts.col_width colsperpage += self.canvas.report_opts.col_width
colsperpage = int(colsperpage / (self.doc.report_opts.max_box_width + colsperpage = int(colsperpage / (self.canvas.report_opts.max_box_width +
self.doc.report_opts.col_width)) self.canvas.report_opts.col_width))
colsperpage = colsperpage or 1 colsperpage = colsperpage or 1
##################### #####################
@ -818,19 +819,19 @@ class AncestorTree(Report):
graph_style = style_sheet.get_draw_style("AC2-box") graph_style = style_sheet.get_draw_style("AC2-box")
graph_style.set_shadow(graph_style.get_shadow(), graph_style.set_shadow(graph_style.get_shadow(),
self.doc.report_opts.box_shadow * scale) self.canvas.report_opts.box_shadow * scale)
graph_style.set_line_width(graph_style.get_line_width() * scale) graph_style.set_line_width(graph_style.get_line_width() * scale)
style_sheet.add_draw_style("AC2-box", graph_style) style_sheet.add_draw_style("AC2-box", graph_style)
graph_style = style_sheet.get_draw_style("AC2-fam-box") graph_style = style_sheet.get_draw_style("AC2-fam-box")
graph_style.set_shadow(graph_style.get_shadow(), graph_style.set_shadow(graph_style.get_shadow(),
self.doc.report_opts.box_shadow * scale) self.canvas.report_opts.box_shadow * scale)
graph_style.set_line_width(graph_style.get_line_width() * scale) graph_style.set_line_width(graph_style.get_line_width() * scale)
style_sheet.add_draw_style("AC2-fam-box", graph_style) style_sheet.add_draw_style("AC2-fam-box", graph_style)
graph_style = style_sheet.get_draw_style("AC2-note-box") graph_style = style_sheet.get_draw_style("AC2-note-box")
#graph_style.set_shadow(graph_style.get_shadow(), #graph_style.set_shadow(graph_style.get_shadow(),
# self.doc.report_opts.box_shadow * scale) # self.canvas.report_opts.box_shadow * scale)
graph_style.set_line_width(graph_style.get_line_width() * scale) graph_style.set_line_width(graph_style.get_line_width() * scale)
style_sheet.add_draw_style("AC2-note-box", graph_style) style_sheet.add_draw_style("AC2-note-box", graph_style)

View File

@ -408,12 +408,12 @@ class RecurseDown:
box.y_cm = last_box.y_cm box.y_cm = last_box.y_cm
box.y_cm += last_box.height box.y_cm += last_box.height
if last_box.boxstr in ["CG2-box", "CG2b-box"]: if last_box.boxstr in ["CG2-box", "CG2b-box"]:
box.y_cm += self.canvas.doc.report_opts.box_shadow box.y_cm += self.canvas.report_opts.box_shadow
if box.boxstr in ["CG2-box", "CG2b-box"]: if box.boxstr in ["CG2-box", "CG2b-box"]:
box.y_cm += self.canvas.doc.report_opts.box_pgap box.y_cm += self.canvas.report_opts.box_pgap
else: else:
box.y_cm += self.canvas.doc.report_opts.box_mgap box.y_cm += self.canvas.report_opts.box_mgap
if box.level[1] == 0 and self.__last_direct[level]: if box.level[1] == 0 and self.__last_direct[level]:
#ok, a new direct descendant. #ok, a new direct descendant.
@ -421,13 +421,13 @@ class RecurseDown:
# self.__last_direct[level].text[0] # self.__last_direct[level].text[0]
if box.father != self.__last_direct[level].father and \ if box.father != self.__last_direct[level].father and \
box.father != self.__last_direct[level]: box.father != self.__last_direct[level]:
box.y_cm += self.canvas.doc.report_opts.box_pgap box.y_cm += self.canvas.report_opts.box_pgap
self.cols[level] = box self.cols[level] = box
if box.level[1] == 0: if box.level[1] == 0:
self.__last_direct[level] = box self.__last_direct[level] = box
box.x_cm = self.canvas.doc.report_opts.spouse_offset * box.level[1] box.x_cm = self.canvas.report_opts.spouse_offset * box.level[1]
self.canvas.set_box_height_width(box) self.canvas.set_box_height_width(box)
@ -950,11 +950,11 @@ class MakeReport(object):
def calc_box(self, box): def calc_box(self, box):
""" calculate the max_box_width and max_box_height for the report """ """ calculate the max_box_width and max_box_height for the report """
width = box.x_cm + box.width width = box.x_cm + box.width
if width > self.canvas.doc.report_opts.max_box_width: if width > self.canvas.report_opts.max_box_width:
self.canvas.doc.report_opts.max_box_width = width self.canvas.report_opts.max_box_width = width
if box.height > self.canvas.doc.report_opts.max_box_height: if box.height > self.canvas.report_opts.max_box_height:
self.canvas.doc.report_opts.max_box_height = box.height self.canvas.report_opts.max_box_height = box.height
while len(self.cols) <= box.level[0]: while len(self.cols) <= box.level[0]:
self.cols.append([]) self.cols.append([])
@ -1154,15 +1154,15 @@ class MakeReport(object):
box.level = (box.level[0] - 1, box.level[1]) box.level = (box.level[0] - 1, box.level[1])
#go ahead and set it now. #go ahead and set it now.
width = self.canvas.doc.report_opts.max_box_width width = self.canvas.report_opts.max_box_width
for box in self.canvas.boxes: for box in self.canvas.boxes:
box.width = width - box.x_cm box.width = width - box.x_cm
box.x_cm += self.canvas.doc.report_opts.littleoffset box.x_cm += self.canvas.report_opts.littleoffset
box.x_cm += (box.level[0] * box.x_cm += (box.level[0] *
(self.canvas.doc.report_opts.col_width + (self.canvas.report_opts.col_width +
self.canvas.doc.report_opts.max_box_width)) self.canvas.report_opts.max_box_width))
box.y_cm += self.canvas.doc.report_opts.littleoffset box.y_cm += self.canvas.report_opts.littleoffset
box.y_cm += self.canvas.title.height box.y_cm += self.canvas.title.height
self.Make_report() self.Make_report()
@ -1264,9 +1264,6 @@ class DescendTree(Report):
self.options = options self.options = options
self.database = database self.database = database
#The canvas that we will put our report on and print off of
self.canvas = Canvas(self.doc)
""" make the report in its full size and pages to print on """ make the report in its full size and pages to print on
scale one or both as needed/desired. scale one or both as needed/desired.
""" """
@ -1278,11 +1275,15 @@ class DescendTree(Report):
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.box_shadow *= self.Connect.get_val('shadowscale') #The canvas that we will put our report on and print off of
self.doc.report_opts.box_pgap *= self.Connect.get_val('box_Yscale') self.canvas = Canvas(self.doc,
self.doc.report_opts.box_mgap *= self.Connect.get_val('box_Yscale') ReportOptions(self.doc, font_normal, "CG2-line"))
self.canvas.report_opts.box_shadow *= \
self.Connect.get_val('shadowscale')
self.canvas.report_opts.box_pgap *= self.Connect.get_val('box_Yscale')
self.canvas.report_opts.box_mgap *= self.Connect.get_val('box_Yscale')
center_id = self.Connect.get_val('pid') center_id = self.Connect.get_val('pid')
@ -1341,9 +1342,9 @@ class DescendTree(Report):
#Setup page information #Setup page information
colsperpage = self.doc.get_usable_width() colsperpage = self.doc.get_usable_width()
colsperpage += self.doc.report_opts.col_width colsperpage += self.canvas.report_opts.col_width
tmp = self.doc.report_opts.max_box_width tmp = self.canvas.report_opts.max_box_width
tmp += self.doc.report_opts.col_width tmp += self.canvas.report_opts.col_width
colsperpage = int(colsperpage / tmp) colsperpage = int(colsperpage / tmp)
colsperpage = colsperpage or 1 colsperpage = colsperpage or 1
@ -1393,13 +1394,13 @@ class DescendTree(Report):
graph_style = style_sheet.get_draw_style("CG2-box") graph_style = style_sheet.get_draw_style("CG2-box")
graph_style.set_shadow(graph_style.get_shadow(), graph_style.set_shadow(graph_style.get_shadow(),
self.doc.report_opts.box_shadow * amount) self.canvas.report_opts.box_shadow * amount)
graph_style.set_line_width(graph_style.get_line_width() * amount) graph_style.set_line_width(graph_style.get_line_width() * amount)
style_sheet.add_draw_style("CG2-box", graph_style) style_sheet.add_draw_style("CG2-box", graph_style)
graph_style = style_sheet.get_draw_style("CG2b-box") graph_style = style_sheet.get_draw_style("CG2b-box")
graph_style.set_shadow(graph_style.get_shadow(), graph_style.set_shadow(graph_style.get_shadow(),
self.doc.report_opts.box_shadow * amount) self.canvas.report_opts.box_shadow * amount)
graph_style.set_line_width(graph_style.get_line_width() * amount) graph_style.set_line_width(graph_style.get_line_width() * amount)
style_sheet.add_draw_style("CG2b-box", graph_style) style_sheet.add_draw_style("CG2b-box", graph_style)

View File

@ -148,10 +148,10 @@ class Canvas(Page):
a group of pages. each page is set is size and shows only a a group of pages. each page is set is size and shows only a
part of what is on the entire canvas part of what is on the entire canvas
""" """
def __init__(self, doc): def __init__(self, doc, report_opts):
Page.__init__(self, self) Page.__init__(self, self)
self.doc = doc self.doc = doc
self.report_opts = None self.report_opts = report_opts
#How many pages are there in the report. one more than real. #How many pages are there in the report. one more than real.
self.x_pages = 1 self.x_pages = 1
@ -181,6 +181,7 @@ class Canvas(Page):
def add_title(self, title): def add_title(self, title):
""" The title must derive from class TitleBox(BoxBase): """ """ The title must derive from class TitleBox(BoxBase): """
self.title = title self.title = title
self.title.cm_y = self.report_opts.littleoffset
def add_note(self, note): def add_note(self, note):
""" The note must derive from class NoteBox(BoxBase, NoteType) """ """ The note must derive from class NoteBox(BoxBase, NoteType) """
@ -211,15 +212,15 @@ class Canvas(Page):
tmp = box.y_cm + box.height tmp = box.y_cm + box.height
if tmp > max_height: if tmp > max_height:
max_height = tmp max_height = tmp
max_width += self.doc.report_opts.box_shadow max_width += self.report_opts.box_shadow
max_width += self.doc.report_opts.littleoffset max_width += self.report_opts.littleoffset
max_height += self.doc.report_opts.box_shadow max_height += self.report_opts.box_shadow
max_height += self.doc.report_opts.littleoffset max_height += self.report_opts.littleoffset
return (max_width, max_height) return (max_width, max_height)
def __scale_canvas(self, scale_amount): def __scale_canvas(self, scale_amount):
""" scales everything up/down depending upon scale_amount """ """ scales everything up/down depending upon scale_amount """
self.doc.report_opts.scale_everything(scale_amount) self.report_opts.scale_everything(scale_amount)
self.title.scale(scale_amount) self.title.scale(scale_amount)
if self.note is not None: if self.note is not None:
self.note.scale(scale_amount) self.note.scale(scale_amount)
@ -294,8 +295,8 @@ class Canvas(Page):
if scale_to_width or scale_to_height: if scale_to_width or scale_to_height:
max_width, max_height = self.canvas.get_report_height_width() max_width, max_height = self.canvas.get_report_height_width()
#max_width += self.doc.report_opts.littleoffset #max_width += self.report_opts.littleoffset
#max_height += self.doc.report_opts.littleoffset #max_height += self.report_opts.littleoffset
""" """
calc - Calculate the scale amount (if any). calc - Calculate the scale amount (if any).
@ -311,7 +312,7 @@ class Canvas(Page):
if scale_to_width: if scale_to_width:
#Check the width of the title #Check the width of the title
title_width = self.title.width title_width = self.title.width
title_width += self.doc.report_opts.littleoffset * 2 title_width += self.report_opts.littleoffset * 2
max_width = max(title_width, max_width) max_width = max(title_width, max_width)
@ -346,7 +347,7 @@ class Canvas(Page):
if scaled_report_to != "width": if scaled_report_to != "width":
#calculate the width of the report #calculate the width of the report
#max_width += self.doc.report_opts.littleoffset #max_width += self.report_opts.littleoffset
max_width += self.doc.paper.get_left_margin() max_width += self.doc.paper.get_left_margin()
max_width += self.doc.paper.get_right_margin() max_width += self.doc.paper.get_right_margin()
@ -354,7 +355,7 @@ class Canvas(Page):
title_width = self.canvas.title.width title_width = self.canvas.title.width
title_width += self.doc.paper.get_left_margin() title_width += self.doc.paper.get_left_margin()
title_width += self.doc.paper.get_right_margin() title_width += self.doc.paper.get_right_margin()
title_width += self.doc.report_opts.littleoffset title_width += self.report_opts.littleoffset
max_width = max(title_width, max_width) max_width = max(title_width, max_width)
size.set_width(max_width) size.set_width(max_width)
@ -363,7 +364,7 @@ class Canvas(Page):
#calculate the height of the report #calculate the height of the report
max_height += self.doc.paper.get_top_margin() max_height += self.doc.paper.get_top_margin()
max_height += self.doc.paper.get_bottom_margin() max_height += self.doc.paper.get_bottom_margin()
#max_height += self.doc.report_opts.littleoffset #max_height += self.report_opts.littleoffset
size.set_height(max_height) size.set_height(max_height)
return scale return scale
@ -372,7 +373,7 @@ class Canvas(Page):
def __paginate_x_offsets(self, colsperpage): def __paginate_x_offsets(self, colsperpage):
""" Go through the boxes and get the x page offsets """ """ Go through the boxes and get the x page offsets """
#fix soon. should not use .level #fix soon. should not use .level
liloffset = self.doc.report_opts.littleoffset liloffset = self.report_opts.littleoffset
x_page_offsets = {0:0} #change me to [] ??? x_page_offsets = {0:0} #change me to [] ???
for box in self.boxes: for box in self.boxes:
x_index = box.level[0] x_index = box.level[0]
@ -388,7 +389,7 @@ class Canvas(Page):
note that the self.boxes needs to be sorted by .y_cm """ note that the self.boxes needs to be sorted by .y_cm """
page_y_top = [0] page_y_top = [0]
page_y_height = [self.doc.get_usable_height()] page_y_height = [self.doc.get_usable_height()]
liloffset = self.doc.report_opts.littleoffset liloffset = self.report_opts.littleoffset
for box in self.boxes: for box in self.boxes:
#check to see if this box cross over to the next (y) page #check to see if this box cross over to the next (y) page
@ -524,7 +525,7 @@ class Canvas(Page):
def __paginate(self, colsperpage): def __paginate(self, colsperpage):
""" take the boxes on the canvas and put them into separate pages. """ take the boxes on the canvas and put them into separate pages.
The boxes need to be sorted by y_cm """ The boxes need to be sorted by y_cm """
liloffset = self.doc.report_opts.littleoffset liloffset = self.report_opts.littleoffset
self.__pages = {} self.__pages = {}
x_page_offsets = self.__paginate_x_offsets(colsperpage) x_page_offsets = self.__paginate_x_offsets(colsperpage)
page_y_top = self.__paginate_y_pages(colsperpage, x_page_offsets) page_y_top = self.__paginate_y_pages(colsperpage, x_page_offsets)
@ -593,6 +594,7 @@ class BoxBase(object):
return return
doc = self.page.canvas.doc doc = self.page.canvas.doc
report_opts = self.page.canvas.report_opts
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
@ -607,10 +609,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 < doc.report_opts.littleoffset*2: xbegin < 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
doc.draw_line(doc.report_opts.line_str, 0, yme, xbegin, yme) doc.draw_line(report_opts.line_str, 0, yme, xbegin, yme)
@ -625,7 +627,6 @@ class TitleBox(BoxBase):
self.boxstr = boxstr self.boxstr = boxstr
if boxstr == "None": if boxstr == "None":
return return
self.cm_y = self.doc.report_opts.littleoffset
style_sheet = self.doc.get_style_sheet() style_sheet = self.doc.get_style_sheet()
style_name = style_sheet.get_draw_style(self.boxstr) style_name = style_sheet.get_draw_style(self.boxstr)
@ -747,7 +748,7 @@ class NoteBox(BoxBase, NoteType):
""" set the x_cm and y_cm given """ set the x_cm and y_cm given
self.doc, leloffset, and title_height """ self.doc, leloffset, and title_height """
liloffset = self.doc.report_opts.littleoffset liloffset = canvas.report_opts.littleoffset
#left or right side #left or right side
if self.value == NoteType.BOTTOMLEFT or \ if self.value == NoteType.BOTTOMLEFT or \
self.value == NoteType.TOPLEFT: self.value == NoteType.TOPLEFT:
@ -815,12 +816,13 @@ class LineBase(object):
# self.start = [self.start] # self.start = [self.start]
start = self.start[0] start = self.start[0]
doc = start.page.canvas.doc doc = start.page.canvas.doc
linestr = doc.report_opts.line_str report_opts = start.page.canvas.report_opts
linestr = report_opts.line_str
xbegin = start.x_cm + start.width - page.page_x_offset xbegin = start.x_cm + start.width - page.page_x_offset
# out 3/4 of the way and x_cm end point(s) # out 3/4 of the way and x_cm end point(s)
x34 = xbegin + (doc.report_opts.col_width * 3/4) x34 = xbegin + (report_opts.col_width * 3/4)
xend = xbegin + doc.report_opts.col_width xend = xbegin + report_opts.col_width
if x34 > 0: # > 0 tell us we are printing on this page. if x34 > 0: # > 0 tell us we are printing on this page.
usable_height = doc.get_usable_height() usable_height = doc.get_usable_height()