0001957: Orientation switch doesn't work for Graphviz reports.

0001940: GS PDF output is broken for Graphiz graphs. Page size depends on dpi

svn: r10346
This commit is contained in:
Brian Matherly 2008-03-20 03:18:35 +00:00
parent b8e54e6e81
commit 5918599acf

View File

@ -110,8 +110,8 @@ class GVDocBase(BaseDoc.BaseDoc,BaseDoc.GVDoc):
inherit from this class will only need to implement the close function. inherit from this class will only need to implement the close function.
The close function will generate the actual file of the appropriate type. The close function will generate the actual file of the appropriate type.
""" """
def __init__(self, options,paper_style): def __init__(self, options, paper_style):
BaseDoc.BaseDoc.__init__(self,None,paper_style,None) BaseDoc.BaseDoc.__init__(self, None, paper_style, None)
self.options = options.handler.options_dict self.options = options.handler.options_dict
self.dot = StringIO() self.dot = StringIO()
@ -132,27 +132,19 @@ class GVDocBase(BaseDoc.BaseDoc,BaseDoc.GVDoc):
self.vpages = self.options['v_pages' ] self.vpages = self.options['v_pages' ]
paper_size = paper_style.get_size() paper_size = paper_style.get_size()
pheight = paper_size.get_height_inches()
pwidth = paper_size.get_width_inches()
# graph size sizew = ( paper_size.get_width() -
if self.paper.get_orientation() == BaseDoc.PAPER_LANDSCAPE: self.paper.get_left_margin() -
rotate = 90 self.paper.get_right_margin() ) / 2.54
sizew = ( paper_size.get_height() - sizeh = ( paper_size.get_height() -
self.paper.get_top_margin() - self.paper.get_top_margin() -
self.paper.get_bottom_margin() ) / 2.54 self.paper.get_bottom_margin() ) / 2.54
sizeh = ( paper_size.get_width() -
self.paper.get_left_margin() -
self.paper.get_right_margin() ) / 2.54
else: pheight = paper_size.get_height_inches()
rotate = 0 pwidth = paper_size.get_width_inches()
sizew = ( paper_size.get_width() -
self.paper.get_left_margin() - xmargin = self.paper.get_left_margin() / 2.54
self.paper.get_right_margin() ) / 2.54 ymargin = self.paper.get_top_margin() / 2.54
sizeh = ( paper_size.get_height() -
self.paper.get_top_margin() -
self.paper.get_bottom_margin() ) / 2.54
sizew = sizew * self.hpages sizew = sizew * self.hpages
sizeh = sizeh * self.vpages sizeh = sizeh * self.vpages
@ -173,9 +165,9 @@ class GVDocBase(BaseDoc.BaseDoc,BaseDoc.GVDoc):
self.write( ' rankdir="%s";\n' % self.rankdir ) self.write( ' rankdir="%s";\n' % self.rankdir )
self.write( ' ranksep="%.2f";\n' % self.ranksep ) self.write( ' ranksep="%.2f";\n' % self.ranksep )
self.write( ' ratio="%s";\n' % self.ratio ) self.write( ' ratio="%s";\n' % self.ratio )
self.write( ' rotate="%d";\n' % rotate )
self.write( ' searchsize="100";\n' ) self.write( ' searchsize="100";\n' )
self.write( ' size="%3.2f,%3.2f"; \n' % (sizew, sizeh) ) self.write( ' size="%3.2f,%3.2f"; \n' % (sizew, sizeh) )
self.write( ' margin="%3.2f,%3.2f"; \n' % (xmargin, ymargin))
self.write( ' splines="true";\n' ) self.write( ' splines="true";\n' )
self.write( '\n' ) self.write( '\n' )
self.write( ' edge [len=0.5 style=solid arrowhead=none ' self.write( ' edge [len=0.5 style=solid arrowhead=none '
@ -322,6 +314,13 @@ class GVDotDoc(GVDocBase):
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class GVPsDoc(GVDocBase): class GVPsDoc(GVDocBase):
def __init__(self, options, paper_style):
# DPI must always be 72 for PDF.
# GV documentation says dpi is only for image formats.
options.handler.options_dict['dpi'] = 72
GVDocBase.__init__(self, options, paper_style)
def close(self): def close(self):
GVDocBase.close(self) GVDocBase.close(self)
@ -496,6 +495,13 @@ class GVGifDoc(GVDocBase):
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class GVPdfGvDoc(GVDocBase): class GVPdfGvDoc(GVDocBase):
def __init__(self, options, paper_style):
# DPI must always be 72 for PDF.
# GV documentation says dpi is only for image formats.
options.handler.options_dict['dpi'] = 72
GVDocBase.__init__(self, options, paper_style)
def close(self): def close(self):
GVDocBase.close(self) GVDocBase.close(self)
@ -526,6 +532,13 @@ class GVPdfGvDoc(GVDocBase):
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class GVPdfGsDoc(GVDocBase): class GVPdfGsDoc(GVDocBase):
def __init__(self, options, paper_style):
# DPI must always be 72 for PDF.
# GV documentation says dpi is only for image formats.
options.handler.options_dict['dpi'] = 72
GVDocBase.__init__(self, options, paper_style)
def close(self): def close(self):
GVDocBase.close(self) GVDocBase.close(self)
@ -793,8 +806,8 @@ class GraphvizReportDialog(ReportDialog):
dpi = NumberOption(_("DPI"), 75, 20, 1200) dpi = NumberOption(_("DPI"), 75, 20, 1200)
dpi.set_help(_( "Dots per inch. When creating images such as " dpi.set_help(_( "Dots per inch. When creating images such as "
".gif or .png files for the web, try numbers " ".gif or .png files for the web, try numbers "
"such as 75 or 100 DPI. When printing, try" "such as 100 or 300 DPI. When creating postscript or "
"300 or 600 DPI.")) "pdf files, use 72 DPI."))
self.options.add_menu_option(category, "dpi", dpi) self.options.add_menu_option(category, "dpi", dpi)
nodesep = NumberOption(_("Node spacing"), 0.20, 0.01, 5.00, 0.01) nodesep = NumberOption(_("Node spacing"), 0.20, 0.01, 5.00, 0.01)