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