diff --git a/ChangeLog b/ChangeLog index 15315dff6..6fe5de1be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-02-14 Brian Matherly + * 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 * src/docgen/HtmlDoc.py: fix html template loading. * src/ReportBase/_ReportDialog.py: fix html template loading. diff --git a/src/BaseDoc.py b/src/BaseDoc.py index ea3c7aa6c..2552d1efc 100644 --- a/src/BaseDoc.py +++ b/src/BaseDoc.py @@ -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)) diff --git a/src/ReportBase/_ReportUtils.py b/src/ReportBase/_ReportUtils.py index 291bc2e48..812c297e6 100644 --- a/src/ReportBase/_ReportUtils.py +++ b/src/ReportBase/_ReportUtils.py @@ -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): diff --git a/src/docgen/PSDrawDoc.py b/src/docgen/PSDrawDoc.py index b40c322a6..5cb332183 100644 --- a/src/docgen/PSDrawDoc.py +++ b/src/docgen/PSDrawDoc.py @@ -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: - 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 diff --git a/src/plugins/FanChart.py b/src/plugins/FanChart.py index a4c442ef4..a20f61a52 100644 --- a/src/plugins/FanChart.py +++ b/src/plugins/FanChart.py @@ -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]: