From eb15b262849b6ef3f050b106cb65fc12774613f9 Mon Sep 17 00:00:00 2001 From: Peter Landgren Date: Tue, 13 May 2008 08:39:27 +0000 Subject: [PATCH] Fix of bugs 2121 and 2134 svn: r10713 --- src/ReportBase/_GraphvizReportDialog.py | 64 +++++++++++++++++++++---- 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/src/ReportBase/_GraphvizReportDialog.py b/src/ReportBase/_GraphvizReportDialog.py index 58ef30860..d9c765ada 100644 --- a/src/ReportBase/_GraphvizReportDialog.py +++ b/src/ReportBase/_GraphvizReportDialog.py @@ -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() @@ -363,6 +366,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() """ @@ -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 @@ -395,6 +405,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() """ @@ -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 @@ -427,6 +444,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() """ @@ -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 @@ -459,6 +483,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() """ @@ -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 @@ -491,6 +522,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() """ @@ -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")