Fix of bugs 2121 and 2134

svn: r10713
This commit is contained in:
Peter Landgren 2008-05-13 08:39:27 +00:00
parent 30ab5de58d
commit eb15b26284

View File

@ -136,12 +136,15 @@ class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
paper_size = paper_style.get_size()
# Subtract 0.01" from the drawing area to make some room between
# this area and the margin in order to compensate for different
# rounding errors internally in dot
sizew = ( paper_size.get_width() -
self._paper.get_left_margin() -
self._paper.get_right_margin() ) / 2.54
self._paper.get_right_margin() ) / 2.54 - 0.01
sizeh = ( paper_size.get_height() -
self._paper.get_top_margin() -
self._paper.get_bottom_margin() ) / 2.54
self._paper.get_bottom_margin() ) / 2.54 - 0.01
pheight = paper_size.get_height_inches()
pwidth = paper_size.get_width_inches()
@ -364,6 +367,13 @@ class GVPsDoc(GVDocBase):
class GVSvgDoc(GVDocBase):
""" GVDoc implementation that generates a .svg file using Graphviz. """
def __init__(self, options, paper_style):
# GV documentation allow multiple pages only for ps format,
# which also includes pdf via ghostscript.
options.menu.get_option_by_name('v_pages').set_value(1)
options.menu.get_option_by_name('h_pages').set_value(1)
GVDocBase.__init__(self, options, paper_style)
def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self)
@ -378,7 +388,7 @@ class GVSvgDoc(GVDocBase):
dotfile.write(self._dot.getvalue())
dotfile.close()
# Generate the PS file.
# Generate the SVG file.
os.system( 'dot -Tsvg -o"%s" "%s"' % (self._filename, tmp_dot) )
# Delete the temporary dot file
@ -396,6 +406,13 @@ class GVSvgDoc(GVDocBase):
class GVSvgzDoc(GVDocBase):
""" GVDoc implementation that generates a .svg file using Graphviz. """
def __init__(self, options, paper_style):
# GV documentation allow multiple pages only for ps format,
# which also includes pdf via ghostscript.
options.menu.get_option_by_name('v_pages').set_value(1)
options.menu.get_option_by_name('h_pages').set_value(1)
GVDocBase.__init__(self, options, paper_style)
def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self)
@ -410,7 +427,7 @@ class GVSvgzDoc(GVDocBase):
dotfile.write(self._dot.getvalue())
dotfile.close()
# Generate the PS file.
# Generate the SVGZ file.
os.system( 'dot -Tsvgz -o"%s" "%s"' % (self._filename, tmp_dot) )
# Delete the temporary dot file
@ -428,6 +445,13 @@ class GVSvgzDoc(GVDocBase):
class GVPngDoc(GVDocBase):
""" GVDoc implementation that generates a .png file using Graphviz. """
def __init__(self, options, paper_style):
# GV documentation allow multiple pages only for ps format,
# which also includes pdf via ghostscript.
options.menu.get_option_by_name('v_pages').set_value(1)
options.menu.get_option_by_name('h_pages').set_value(1)
GVDocBase.__init__(self, options, paper_style)
def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self)
@ -442,7 +466,7 @@ class GVPngDoc(GVDocBase):
dotfile.write(self._dot.getvalue())
dotfile.close()
# Generate the PS file.
# Generate the PNG file.
os.system( 'dot -Tpng -o"%s" "%s"' % (self._filename, tmp_dot) )
# Delete the temporary dot file
@ -460,6 +484,13 @@ class GVPngDoc(GVDocBase):
class GVJpegDoc(GVDocBase):
""" GVDoc implementation that generates a .jpg file using Graphviz. """
def __init__(self, options, paper_style):
# GV documentation allow multiple pages only for ps format,
# which also includes pdf via ghostscript.
options.menu.get_option_by_name('v_pages').set_value(1)
options.menu.get_option_by_name('h_pages').set_value(1)
GVDocBase.__init__(self, options, paper_style)
def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self)
@ -474,7 +505,7 @@ class GVJpegDoc(GVDocBase):
dotfile.write(self._dot.getvalue())
dotfile.close()
# Generate the PS file.
# Generate the JPEG file.
os.system( 'dot -Tjpg -o"%s" "%s"' % (self._filename, tmp_dot) )
# Delete the temporary dot file
@ -492,6 +523,13 @@ class GVJpegDoc(GVDocBase):
class GVGifDoc(GVDocBase):
""" GVDoc implementation that generates a .gif file using Graphviz. """
def __init__(self, options, paper_style):
# GV documentation allow multiple pages only for ps format,
# which also includes pdf via ghostscript.
options.menu.get_option_by_name('v_pages').set_value(1)
options.menu.get_option_by_name('h_pages').set_value(1)
GVDocBase.__init__(self, options, paper_style)
def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self)
@ -506,7 +544,7 @@ class GVGifDoc(GVDocBase):
dotfile.write(self._dot.getvalue())
dotfile.close()
# Generate the PS file.
# Generate the GIF file.
os.system( 'dot -Tgif -o"%s" "%s"' % (self._filename, tmp_dot) )
# Delete the temporary dot file
@ -528,6 +566,10 @@ class GVPdfGvDoc(GVDocBase):
# DPI must always be 72 for PDF.
# GV documentation says dpi is only for image formats.
options.menu.get_option_by_name('dpi').set_value(72)
# GV documentation allow multiple pages only for ps format,
# which also includes pdf via ghostscript.
options.menu.get_option_by_name('v_pages').set_value(1)
options.menu.get_option_by_name('h_pages').set_value(1)
GVDocBase.__init__(self, options, paper_style)
def close(self):
@ -789,14 +831,18 @@ class GraphvizReportDialog(ReportDialog):
h_pages.set_help(_("GraphViz can create very large graphs by "
"spreading the graph across a rectangular "
"array of pages. This controls the number "
"of pages in the array horizontally."))
"pages in the array horizontally. "
"Only valid for dot, postscript and pdf "
"via Ghostscript."))
self.options.add_menu_option(category, "h_pages", h_pages)
v_pages = NumberOption(_("Number of Vertical Pages"), 1, 1, 25)
v_pages.set_help(_("GraphViz can create very large graphs by "
"spreading the graph across a rectangular "
"array of pages. This controls the number "
"of pages in the array vertically."))
"pages in the array vertically. "
"Only valid for dot, postscript and pdf "
"via Ghostscript."))
self.options.add_menu_option(category, "v_pages", v_pages)
page_dir = EnumeratedListOption(_("Paging Direction"), "BL")