small updates. remove box.shadow and used report_opt.box_shadow

also removed .prev from Descendant reports.  
updated shadows to be more consistent.



svn: r16380
This commit is contained in:
Craig J. Anderson 2011-01-14 19:20:19 +00:00
parent 20f0e5d386
commit b159aa02c2
3 changed files with 60 additions and 62 deletions

View File

@ -34,6 +34,10 @@ def log2(val):
"""
return int(math.log10(val)/math.log10(2))
def X_INDEX(level):
""" calculate the row that this person is in """
return log2(level)
from gen.ggettext import sgettext as _
#------------------------------------------------------------------------
@ -44,8 +48,12 @@ from gen.ggettext import sgettext as _
#from Errors import ReportError
from gen.plug.menu import BooleanOption, NumberOption, StringOption, \
EnumeratedListOption, TextOption, PersonOption
from gen.plug.menu import BooleanOption
from gen.plug.menu import NumberOption
from gen.plug.menu import StringOption
from gen.plug.menu import EnumeratedListOption
from gen.plug.menu import TextOption
from gen.plug.menu import PersonOption
from gen.plug.report import Report
from gen.plug.report import utils as ReportUtils
@ -79,10 +87,6 @@ class AncestorBoxBase(BoxBase):
BoxBase.__init__(self)
self.boxstr = boxstr
def x_index(self, level):
""" calculate the row that this person is in """
return log2(level)
def y_index(self, max_gen):
""" Calculate the column or generation that this person is in. """
x_level = self.level[0]
@ -98,7 +102,7 @@ class PersonBox(AncestorBoxBase):
"""
def __init__(self, level):
AncestorBoxBase.__init__(self, "AC2-box")
self.level = (self.x_index(level), level)
self.level = (X_INDEX(level), level)
class FamilyBox(AncestorBoxBase):
"""
@ -106,12 +110,8 @@ class FamilyBox(AncestorBoxBase):
"""
def __init__(self, level):
AncestorBoxBase.__init__(self, "AC2-fam-box")
self.level = (self.x_index(level)+1, level)
self.level = (X_INDEX(level)+1, level)
#def x_index(self):
# """ calculate the row that this person is in """
# return log2(self.level[0]) +1
def y_index(self, max_gen):
""" Calculate the column or generation that this person is in. """
x_level = self.level[0] -1
@ -451,7 +451,7 @@ class MakeReport():
self.canvas.set_box_height_width(box)
if box.width > self.doc.report_opts.max_box_width:
self.doc.report_opts.max_box_width = box.width + box.shadow
self.doc.report_opts.max_box_width = box.width #+ box.shadow
if box.level[1] > 0:
if box.level[1] % 2 == 0 and box.height > self.father_ht:
@ -887,6 +887,7 @@ class AncestorTree2Options(MenuReportOptions):
para_style.set_description(_('The basic style used for the ' +
'text display.'))
default_style.add_paragraph_style("AC2-Normal", para_style)
box_shadow = PT2CM(font.get_size()) * .6
font = FontStyle()
font.set_size(16)
@ -901,7 +902,7 @@ class AncestorTree2Options(MenuReportOptions):
## Draw styles
graph_style = GraphicsStyle()
graph_style.set_paragraph_style("AC2-Normal")
graph_style.set_shadow(1, PT2CM(9)) #shadow set by text size
graph_style.set_shadow(1, box_shadow) #shadow set by text size
graph_style.set_fill_color((255, 255, 255))
default_style.add_draw_style("AC2-box", graph_style)

View File

@ -39,8 +39,13 @@ except:
from Errors import ReportError
from gen.plug.menu import TextOption, NumberOption, EnumeratedListOption, \
StringOption, BooleanOption, PersonOption, FamilyOption
from gen.plug.menu import TextOption
from gen.plug.menu import NumberOption
from gen.plug.menu import EnumeratedListOption
from gen.plug.menu import StringOption
from gen.plug.menu import BooleanOption
from gen.plug.menu import PersonOption
from gen.plug.menu import FamilyOption
from gen.plug.report import Report
from gen.plug.report import utils as ReportUtils
@ -73,7 +78,6 @@ class DescendantBoxBase(BoxBase):
BoxBase.__init__(self)
self.boxstr = boxstr
self.next = None
self.prev = None
self.line_to = None
self.father = None
@ -91,7 +95,6 @@ class PersonBox(DescendantBoxBase):
def __init__(self, level, boldable = 0):
DescendantBoxBase.__init__(self, "CG2-box")
self.level = level
self.shadow = PT2CM(9) * .6
def set_bold(self):
""" update me to a bolded box """
@ -374,6 +377,7 @@ class RecurseDown:
self.famalies_seen = []
self.cols = []
self.__last_direct = []
gui = GuiConnect()
self.do_gparents = gui.get_val('show_gparents')
@ -396,7 +400,7 @@ class RecurseDown:
def add_to_col(self, box):
"""
Add the box to a column on the canvas. we will do these things:
set the .next .prev attribs for the boxs in this col
set the .next attrib for the boxs in this col
get the height and width of this box and set it no the column
also we set the .x_cm to any s_level (indentation) here
we will calculate the real .x_cm later (with indentation)
@ -406,22 +410,35 @@ class RecurseDown:
#make the column list of people
while len(self.cols) <= level:
self.cols.append(None)
self.__last_direct.append(None)
if self.cols[level] is not None:
self.cols[level].next = box
box.prev = self.cols[level]
last_box = self.cols[level]
last_box.next = box
#calculate the .y_cm for this box.
box.y_cm = last_box.y_cm
box.y_cm += last_box.height
if last_box.boxstr == "CG2-box":
box.y_cm += self.canvas.doc.report_opts.box_shadow
if box.boxstr == "CG2-box":
box.y_cm += self.canvas.doc.report_opts.box_pgap
else:
box.y_cm += self.canvas.doc.report_opts.box_mgap
if box.level[1] == 0 and self.__last_direct[level]:
if box.father != self.__last_direct[level].father:
box.y_cm += self.canvas.doc.report_opts.box_pgap
self.cols[level] = box
if box.level[1] == 0:
self.__last_direct[level] = box
box.x_cm = self.canvas.doc.report_opts.spouse_offset * box.level[1]
self.canvas.set_box_height_width(box)
tmp = box.prev
if tmp is not None:
#set my y_cm.
box.y_cm = tmp.y_cm + tmp.height + tmp.shadow
def add_person_box(self, level, indi_handle, fams_handle, father):
""" Makes a person box and add that person into the Canvas. """
@ -449,21 +466,6 @@ class RecurseDown:
myself.calc_text(self.database, indi_handle, fams_handle)
self.add_to_col(myself)
if myself.y_cm != 0.0:
myself.y_cm += self.canvas.doc.report_opts.box_pgap
#check to see if the direct decendant above me is a sibling or other
if myself.level[1] == 0:
sibling = True
this_box = myself.prev
while this_box is not None:
if this_box.level[1] == 0:
if this_box.father != myself.father:
sibling = False
break
this_box = this_box.prev
if sibling == False:
myself.y_cm += self.canvas.doc.report_opts.box_pgap
self.canvas.add_box(myself)
@ -479,8 +481,6 @@ class RecurseDown:
myself.calc_text(self.database, indi_handle, fams_handle)
self.add_to_col(myself)
if myself.y_cm != 0.0:
myself.y_cm += self.canvas.doc.report_opts.box_mgap
self.canvas.add_box(myself)
@ -1655,8 +1655,7 @@ class Descend2TreeOptions(MenuReportOptions):
#Set the size of the shadow based on the font size! Much better
#will be set later too.
tmp = PT2CM(font.get_size())
box_shadow = tmp * .6
box_shadow = PT2CM(font.get_size()) * .6
font.set_bold(True)
para_style = ParagraphStyle()

View File

@ -204,12 +204,16 @@ class Canvas(Page):
max_width = 0
max_height = 0
for box in self.boxes:
tmp = box.x_cm + box.width + box.shadow
tmp = box.x_cm + box.width
if tmp > max_width:
max_width = tmp
tmp = box.y_cm + box.height + box.shadow
tmp = box.y_cm + box.height
if tmp > max_height:
max_height = tmp
max_width += self.doc.report_opts.box_shadow
max_width += self.doc.report_opts.littleoffset
max_height += self.doc.report_opts.box_shadow
max_height += self.doc.report_opts.littleoffset
return (max_width, max_height)
def __scale_canvas(self, scale_amount):
@ -223,7 +227,7 @@ class Canvas(Page):
box.scale(scale_amount)
def set_box_height_width(self, box):
""" Sets the .width .height and .shadow of a box. """
""" Sets the .width and .height of a box. """
if box.boxstr == "None":
box.height = box.width = 0
return
@ -242,12 +246,7 @@ class Canvas(Page):
height = len(box.text) * font.get_size() * 1.5
height += 1.0/2.0 * font.get_size() #funny number(s) based upon font.
box.height = PT2CM(height)
style_sheet = self.doc.get_style_sheet()
style = style_sheet.get_draw_style(box.boxstr)
if style.get_shadow():
box.shadow = style.get_shadow_space()
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 """
@ -283,8 +282,8 @@ class Canvas(Page):
if scale_to_width or scale_to_height:
max_width, max_height = self.canvas.get_report_height_width()
max_width += self.doc.report_opts.littleoffset
max_height += self.doc.report_opts.littleoffset
#max_width += self.doc.report_opts.littleoffset
#max_height += self.doc.report_opts.littleoffset
"""
calc - Calculate the scale amount (if any).
@ -334,7 +333,7 @@ class Canvas(Page):
if scaled_report_to != "width":
#calculate the width of the report
max_width += self.doc.report_opts.littleoffset
#max_width += self.doc.report_opts.littleoffset
max_width += self.doc.paper.get_left_margin()
max_width += self.doc.paper.get_right_margin()
@ -351,7 +350,7 @@ class Canvas(Page):
#calculate the height of the report
max_height += self.doc.paper.get_top_margin()
max_height += self.doc.paper.get_bottom_margin()
max_height += self.doc.report_opts.littleoffset
#max_height += self.doc.report_opts.littleoffset
size.set_height(max_height)
return scale
@ -380,7 +379,7 @@ class Canvas(Page):
for box in self.boxes:
#check to see if this box cross over to the next (y) page
height = box.y_cm + liloffset + box.height + box.shadow/2
height = box.y_cm + liloffset + box.height #+ box.shadow/2
if height > page_y_height[-1]:
#we went off the end
@ -560,7 +559,6 @@ class BoxBase(object):
self.y_cm = 0.0
self.width = 0.0
self.height = 0.0
self.shadow = 0.0
def scale(self, scale_amount):
""" Scale the amounts """
@ -568,7 +566,6 @@ class BoxBase(object):
self.y_cm *= scale_amount
self.width *= scale_amount
self.height *= scale_amount
self.shadow *= scale_amount
def display(self):
""" display the box accounting for page x, y offsets
@ -844,11 +841,12 @@ class ReportOptions(object):
""" initalize various report variables that are used """
self.box_pgap = PT2CM(1.25*normal_font.get_size()) #gap between persons
self.box_mgap = self.box_pgap /2 #gap between marriage information
self.box_shadow = PT2CM(9) #size of normal text
self.box_shadow = PT2CM(normal_font.get_size()) * .6 #normal text
self.spouse_offset = PT2CM(doc.string_width(normal_font, "0"))
self.col_width = PT2CM(doc.string_width(normal_font, "(000,0)"))
self.littleoffset = PT2CM(1)
self.x_cm_cols = [self.littleoffset]
#Things that will get added later
self.max_box_width = 0