* src/docgen/PSDrawDoc.py: remove draw_wedge from BaseDoc

* src/ReportBase/_ReportUtils.py: remove draw_wedge from BaseDoc
* src/plugins/FanChart.py: remove draw_wedge from BaseDoc
* src/BaseDoc.py: remove draw_wedge from BaseDoc

svn: r8121
This commit is contained in:
Brian Matherly 2007-02-15 04:07:53 +00:00
parent 5b457e10bd
commit d5077d219a
5 changed files with 63 additions and 108 deletions

View File

@ -1,3 +1,9 @@
2007-02-14 Brian Matherly <brian@gramps-project.org>
* src/docgen/PSDrawDoc.py: remove draw_wedge from BaseDoc
* src/ReportBase/_ReportUtils.py: remove draw_wedge from BaseDoc
* src/plugins/FanChart.py: remove draw_wedge from BaseDoc
* src/BaseDoc.py: remove draw_wedge from BaseDoc
2007-02-14 Brian Matherly <brian@gramps-project.org>
* src/docgen/HtmlDoc.py: fix html template loading.
* src/ReportBase/_ReportDialog.py: fix html template loading.

View File

@ -66,7 +66,6 @@ __revision__ = "Revision:$Id$"
#
#-------------------------------------------------------------------------
import os
from math import pi, cos, sin
from xml.sax.saxutils import escape
def escxml(d):
@ -1445,55 +1444,3 @@ class BaseDoc:
def draw_line(self, style, x1, y1, x2, y2):
pass
def draw_wedge(self, style, centerx, centery, radius, start_angle,
end_angle, short_radius=0):
assert(self.init_called)
while end_angle < start_angle:
end_angle += 360
p = []
degreestoradians = pi / 180.0
radiansdelta = degreestoradians / 2
sangle = start_angle * degreestoradians
eangle = end_angle * degreestoradians
while eangle < sangle:
eangle = eangle + 2 * pi
angle = sangle
if short_radius == 0:
if (end_angle - start_angle) != 360:
p.append((centerx, centery))
else:
origx = (centerx + cos(angle) * short_radius)
origy = (centery + sin(angle) * short_radius)
p.append((origx, origy))
while angle < eangle:
x = centerx + cos(angle) * radius
y = centery + sin(angle) * radius
p.append((x, y))
angle = angle + radiansdelta
x = centerx + cos(eangle) * radius
y = centery + sin(eangle) * radius
p.append((x, y))
if short_radius:
x = centerx + cos(eangle) * short_radius
y = centery + sin(eangle) * short_radius
p.append((x, y))
angle = eangle
while angle >= sangle:
x = centerx + cos(angle) * short_radius
y = centery + sin(angle) * short_radius
p.append((x, y))
angle = angle - radiansdelta
self.draw_path(style, p)
delta = (eangle - sangle) / 2.0
rad = short_radius + (radius - short_radius) / 2.0
return ( (centerx + cos(sangle + delta) * rad),
(centery + sin(sangle + delta) * rad))

View File

@ -865,7 +865,61 @@ def rgb_color(color):
g = float(color[1])/255.0
b = float(color[2])/255.0
return (r,g,b)
def draw_wedge(doc, style, centerx, centery, radius, start_angle,
end_angle, short_radius=0):
from math import pi, cos, sin
while end_angle < start_angle:
end_angle += 360
p = []
degreestoradians = pi / 180.0
radiansdelta = degreestoradians / 2
sangle = start_angle * degreestoradians
eangle = end_angle * degreestoradians
while eangle < sangle:
eangle = eangle + 2 * pi
angle = sangle
if short_radius == 0:
if (end_angle - start_angle) != 360:
p.append((centerx, centery))
else:
origx = (centerx + cos(angle) * short_radius)
origy = (centery + sin(angle) * short_radius)
p.append((origx, origy))
while angle < eangle:
x = centerx + cos(angle) * radius
y = centery + sin(angle) * radius
p.append((x, y))
angle = angle + radiansdelta
x = centerx + cos(eangle) * radius
y = centery + sin(eangle) * radius
p.append((x, y))
if short_radius:
x = centerx + cos(eangle) * short_radius
y = centery + sin(eangle) * short_radius
p.append((x, y))
angle = eangle
while angle >= sangle:
x = centerx + cos(angle) * short_radius
y = centery + sin(angle) * short_radius
p.append((x, y))
angle = angle - radiansdelta
doc.draw_path(style, p)
delta = (eangle - sangle) / 2.0
rad = short_radius + (radius - short_radius) / 2.0
return ( (centerx + cos(sangle + delta) * rad),
(centery + sin(sangle + delta) * rad))
def draw_pie_chart(doc, center_x, center_y, radius, data, start=0):
"""
Draws a pie chart in the specified document. The data passed is plotted as
@ -900,7 +954,7 @@ def draw_pie_chart(doc, center_x, center_y, radius, data, start=0):
for item in data:
incr = 360.0*(item[1]/total)
doc.draw_wedge(item[0], center_x, center_y, radius, start, start + incr)
draw_wedge(doc,item[0], center_x, center_y, radius, start, start + incr)
start += incr
def draw_legend(doc, start_x, start_y, data, title, label_style):

View File

@ -223,58 +223,6 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write(fdef)
self.f.write('(%s) show grestore\n' % text)
def draw_wedge(self, style, centerx, centery, radius, start_angle,
end_angle, short_radius=0):
while end_angle < start_angle:
end_angle += 360
p = []
degreestoradians = pi/180.0
radiansdelta = degreestoradians/2
sangle = start_angle*degreestoradians
eangle = end_angle*degreestoradians
while eangle<sangle:
eangle = eangle+2*pi
angle = sangle
if short_radius == 0:
if (end_angle - start_angle) != 360:
p.append((centerx,centery))
else:
origx = (centerx + cos(angle)*short_radius)
origy = (centery + sin(angle)*short_radius)
p.append((origx, origy))
while angle<eangle:
x = centerx + cos(angle)*radius
y = centery + sin(angle)*radius
p.append((x,y))
angle = angle+radiansdelta
x = centerx + cos(eangle)*radius
y = centery + sin(eangle)*radius
p.append((x,y))
if short_radius:
x = centerx + cos(eangle)*short_radius
y = centery + sin(eangle)*short_radius
p.append((x,y))
angle = eangle
while angle>=sangle:
x = centerx + cos(angle)*short_radius
y = centery + sin(angle)*short_radius
p.append((x,y))
angle = angle-radiansdelta
self.draw_path(style,p)
delta = (eangle - sangle)/2.0
rad = short_radius + (radius-short_radius)/2.0
return ( (centerx + cos(sangle+delta) * rad),
(centery + sin(sangle+delta) * rad))
def rotate_text(self,style,text,x,y,angle):
x += self.lmargin

View File

@ -288,7 +288,7 @@ class FanChart(Report):
for index in range(segments - 1, 2*segments - 1):
start_angle = end_angle
end_angle = start_angle + delta
(xc,yc) = self.doc.draw_wedge(background_style, x, y, rad2,
(xc,yc) = ReportUtils.draw_wedge(self.doc,background_style, x, y, rad2,
start_angle, end_angle, rad1)
if self.map[index]:
if (generation == 0) and self.full_circle:
@ -320,7 +320,7 @@ class FanChart(Report):
for index in range(segments - 1, 2*segments - 1):
start_angle = end_angle
end_angle = start_angle + delta
(xc,yc) = self.doc.draw_wedge(background_style, x, y, rad2,
(xc,yc) = ReportUtils.draw_wedge(self.doc,background_style, x, y, rad2,
start_angle, end_angle, rad1)
text_angle += delta
if self.map[index]: