* src/BaseDoc.py: Scaleable shadow
* src/plugins/AncestorChart2.py: Scale to page implemented * src/docgen/PdfDoc.py: Scalable shadow svn: r2609
This commit is contained in:
parent
3736aa58ef
commit
b56cdceddf
@ -979,6 +979,7 @@ class GraphicsStyle:
|
|||||||
self.width = obj.width
|
self.width = obj.width
|
||||||
self.para_name = obj.para_name
|
self.para_name = obj.para_name
|
||||||
self.shadow = obj.shadow
|
self.shadow = obj.shadow
|
||||||
|
self.shadow_space = obj.shadow_space
|
||||||
self.color = obj.color
|
self.color = obj.color
|
||||||
self.fill_color = obj.fill_color
|
self.fill_color = obj.fill_color
|
||||||
self.lwidth = obj.lwidth
|
self.lwidth = obj.lwidth
|
||||||
@ -988,6 +989,7 @@ class GraphicsStyle:
|
|||||||
self.width = 0
|
self.width = 0
|
||||||
self.para_name = ""
|
self.para_name = ""
|
||||||
self.shadow = 0
|
self.shadow = 0
|
||||||
|
self.shadow_space = 0.2
|
||||||
self.lwidth = 0.5
|
self.lwidth = 0.5
|
||||||
self.color = (0,0,0)
|
self.color = (0,0,0)
|
||||||
self.fill_color = (255,255,255)
|
self.fill_color = (255,255,255)
|
||||||
@ -1014,8 +1016,12 @@ class GraphicsStyle:
|
|||||||
def set_paragraph_style(self,val):
|
def set_paragraph_style(self,val):
|
||||||
self.para_name = val
|
self.para_name = val
|
||||||
|
|
||||||
def set_shadow(self,val):
|
def set_shadow(self,val,space=0.2):
|
||||||
self.shadow = val
|
self.shadow = val
|
||||||
|
self.shadow_space = space
|
||||||
|
|
||||||
|
def get_shadow_space(self):
|
||||||
|
return self.shadow_space
|
||||||
|
|
||||||
def set_color(self,val):
|
def set_color(self,val):
|
||||||
self.color = val
|
self.color = val
|
||||||
|
@ -413,10 +413,11 @@ class PdfDoc(BaseDoc.BaseDoc):
|
|||||||
w = box_style.get_width()*cm
|
w = box_style.get_width()*cm
|
||||||
h = box_style.get_height()*cm
|
h = box_style.get_height()*cm
|
||||||
|
|
||||||
|
sspace = box_style.get_shadow_space()
|
||||||
if box_style.get_shadow():
|
if box_style.get_shadow():
|
||||||
col = make_color((0xc0,0xc0,0xc0))
|
col = make_color((0xc0,0xc0,0xc0))
|
||||||
r = reportlab.graphics.shapes.Rect((x+0.2)*cm,
|
r = reportlab.graphics.shapes.Rect((x+sspace)*cm,
|
||||||
(y-0.2)*cm-h,
|
(y-sspace)*cm-h,
|
||||||
w,h,
|
w,h,
|
||||||
fillColor=col,
|
fillColor=col,
|
||||||
strokeColor=col)
|
strokeColor=col)
|
||||||
@ -433,7 +434,7 @@ class PdfDoc(BaseDoc.BaseDoc):
|
|||||||
|
|
||||||
size = p.get_font().get_size()
|
size = p.get_font().get_size()
|
||||||
|
|
||||||
x = x + 0.2
|
x = x + sspace
|
||||||
if text != "":
|
if text != "":
|
||||||
lines = text.split('\n')
|
lines = text.split('\n')
|
||||||
self.left_print(lines,p.get_font(),x*cm,y*cm - size)
|
self.left_print(lines,p.get_font(),x*cm,y*cm - size)
|
||||||
|
@ -168,7 +168,8 @@ class AncestorChart:
|
|||||||
else:
|
else:
|
||||||
self.standalone = 0
|
self.standalone = 0
|
||||||
self.font = self.doc.style_list["AC-Normal"].get_font()
|
self.font = self.doc.style_list["AC-Normal"].get_font()
|
||||||
self.calc()
|
|
||||||
|
self.filter(self.start,1)
|
||||||
|
|
||||||
keys = self.map.keys()
|
keys = self.map.keys()
|
||||||
keys.sort()
|
keys.sort()
|
||||||
@ -177,6 +178,7 @@ class AncestorChart:
|
|||||||
self.genchart = GenChart(max_key+1)
|
self.genchart = GenChart(max_key+1)
|
||||||
for key in self.map.keys():
|
for key in self.map.keys():
|
||||||
self.genchart.set(key,self.map[key])
|
self.genchart.set(key,self.map[key])
|
||||||
|
self.calc()
|
||||||
|
|
||||||
def filter(self,person,index):
|
def filter(self,person,index):
|
||||||
"""traverse the ancestors recursively until either the end
|
"""traverse the ancestors recursively until either the end
|
||||||
@ -233,15 +235,28 @@ class AncestorChart:
|
|||||||
the elements on a page.
|
the elements on a page.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.filter(self.start,1)
|
self.genchart.compress()
|
||||||
|
|
||||||
self.box_pad_pts = 5
|
self.box_pad_pts = 5
|
||||||
uh = self.doc.get_usable_height()
|
uh = self.doc.get_usable_height()
|
||||||
uw = self.doc.get_usable_width() - pt2cm(2*self.box_pad_pts)
|
uw = self.doc.get_usable_width() - pt2cm(2*self.box_pad_pts)
|
||||||
|
|
||||||
|
self.box_width = pt2cm(self.box_width)
|
||||||
self.height = self.lines*pt2cm(1.25*self.font.get_size())
|
self.height = self.lines*pt2cm(1.25*self.font.get_size())
|
||||||
|
|
||||||
self.box_width = pt2cm(self.box_width)
|
force_fit = 1
|
||||||
|
self.scale = 1
|
||||||
|
|
||||||
|
if force_fit:
|
||||||
|
(maxy,maxx) = self.genchart.dimensions()
|
||||||
|
|
||||||
|
bw = (self.box_width+pt2cm(10))/(uw/maxx)
|
||||||
|
bh = self.height/(uh/maxy)
|
||||||
|
|
||||||
|
self.scale = max(bw,bh)
|
||||||
|
self.box_width = self.box_width/self.scale
|
||||||
|
self.height = self.height/self.scale
|
||||||
|
self.box_pad_pts = 5/self.scale
|
||||||
|
|
||||||
maxh = int(uh/self.height)
|
maxh = int(uh/self.height)
|
||||||
maxw = int(uw/self.box_width)
|
maxw = int(uw/self.box_width)
|
||||||
@ -257,10 +272,11 @@ class AncestorChart:
|
|||||||
xstart = pt2cm(2)
|
xstart = pt2cm(2)
|
||||||
ystart = -self.height/2.0
|
ystart = -self.height/2.0
|
||||||
self.delta = pt2cm(10) + self.box_width
|
self.delta = pt2cm(10) + self.box_width
|
||||||
# delta = pt2cm(10)+ uw/self.generations_per_page
|
|
||||||
|
|
||||||
self.x = [ xstart ]
|
self.x = [ xstart ]
|
||||||
self.y = [ ystart + uh/2.0 ]
|
self.y = [ ystart + uh/2.0 ]
|
||||||
|
|
||||||
|
self.font.set_size(self.font.get_size()/self.scale)
|
||||||
|
|
||||||
for val in range(1,self.generations_per_page):
|
for val in range(1,self.generations_per_page):
|
||||||
xstart += self.delta
|
xstart += self.delta
|
||||||
@ -274,7 +290,7 @@ class AncestorChart:
|
|||||||
g.set_height(self.height)
|
g.set_height(self.height)
|
||||||
g.set_width(self.box_width)
|
g.set_width(self.box_width)
|
||||||
g.set_paragraph_style("AC-Normal")
|
g.set_paragraph_style("AC-Normal")
|
||||||
g.set_shadow(1)
|
g.set_shadow(1,0.2/self.scale)
|
||||||
g.set_fill_color((255,255,255))
|
g.set_fill_color((255,255,255))
|
||||||
self.doc.add_draw_style("box",g)
|
self.doc.add_draw_style("box",g)
|
||||||
|
|
||||||
@ -292,8 +308,6 @@ class AncestorChart:
|
|||||||
self.get_numbers((start*2)+1,index+1,vals)
|
self.get_numbers((start*2)+1,index+1,vals)
|
||||||
|
|
||||||
def print_page(self,start,generation, page):
|
def print_page(self,start,generation, page):
|
||||||
self.genchart.compress()
|
|
||||||
# self.genchart.display()
|
|
||||||
(maxy,maxx) = self.genchart.dimensions()
|
(maxy,maxx) = self.genchart.dimensions()
|
||||||
self.doc.start_page()
|
self.doc.start_page()
|
||||||
for y in range(0,maxy):
|
for y in range(0,maxy):
|
||||||
|
Loading…
Reference in New Issue
Block a user