* src/plugins/GraphViz.py: Use single margin value, properly use

cm for margin, properly use 2 digits after converting to inches.


svn: r4912
This commit is contained in:
Alex Roitman
2005-07-08 22:14:07 +00:00
parent dc3bfa1a15
commit 0da65704b9
2 changed files with 24 additions and 35 deletions

View File

@@ -1,3 +1,7 @@
2005-07-08 Alex Roitman <shura@gramps-project.org>
* src/plugins/GraphViz.py: Use single margin value, properly use
cm for margin, properly use 2 digits after converting to inches.
2005-07-07 Julio Sanchez <jsanchez@users.sourceforge.net>
* src/docgen/OpenOfficeDoc.py: Compute correctly the draw:viewBox to
please some versions of OpenOffice.org

View File

@@ -128,8 +128,7 @@ class GraphViz:
rankdir - Graph direction
color - Whether to use outline, colored outline or filled color in graph
dashedl - Whether to use dashed lines for non-birth relationships.
margtb - Top & bottom margins, in cm.
marglr - Left & right margins, in cm.
margin - Margins, in cm.
pagesh - Number of pages in horizontal direction.
pagesv - Number of pages in vertical direction.
"""
@@ -156,8 +155,7 @@ class GraphViz:
options = options_class.handler.options_dict
self.hpages = options['pagesh']
self.vpages = options['pagesv']
self.lr_margin = options['marglr']
self.tb_margin = options['margtb']
self.margin = round(options['margin']/2.54,2)
self.includeid = options['incid']
self.includedates = options['incdate']
self.includeurl = options['url']
@@ -202,15 +200,13 @@ class GraphViz:
self.f.write("bgcolor=white;\n")
self.f.write("rankdir=%s;\n" % self.rankdir)
self.f.write("center=1;\n")
self.f.write("margin=0.5;\n")
self.f.write("margin=%3.2f;\n" % self.margin)
self.f.write("ratio=fill;\n")
self.f.write("size=\"%3.1f,%3.1f\";\n" % (
(self.width*self.hpages)-(self.lr_margin*2)
-((self.hpages-1)*1.0),
(self.height*self.vpages)-(self.tb_margin*2)
-((self.vpages-1)*1.0))
)
self.f.write("page=\"%3.1f,%3.1f\";\n" % (self.width,self.height))
self.f.write("size=\"%3.2f,%3.2f\";\n" % (
(self.width-self.margin*2)*self.hpages,
(self.height-self.margin*2)*self.vpages
))
self.f.write("page=\"%3.2f,%3.2f\";\n" % (self.width,self.height))
if self.orient == PAPER_LANDSCAPE:
self.f.write("rotate=90;\n")
@@ -399,12 +395,11 @@ class GraphViz:
self.f.write(" * colorize : %s\n" % bool(self.colorize))
self.f.write(" * dotted adoptions : %s\n" % bool(self.adoptionsdashed))
self.f.write(" * show family nodes : %s\n" % bool(self.show_families))
self.f.write(" * margins top/bottom : %s\n" % self.tb_margin)
self.f.write(" * left/right : %s\n" % self.lr_margin)
self.f.write(" * margin : %3.2fin\n" % self.margin)
self.f.write(" * pages horizontal : %s\n" % self.hpages)
self.f.write(" * vertical : %s\n" % self.vpages)
self.f.write(" * page width : %sin\n" % self.width)
self.f.write(" * height : %sin\n" % self.height)
self.f.write(" * page width : %3.2fin\n" % self.width)
self.f.write(" * height : %3.2fin\n" % self.height)
self.f.write(" *\n")
self.f.write(" * Generated on %s by GRAMPS\n" % asctime())
self.f.write(" */\n\n")
@@ -438,8 +433,7 @@ class GraphVizOptions(ReportOptions.ReportOptions):
'rankdir' : "LR",
'color' : "filled",
'dashedl' : 1,
'margtb' : 0.5,
'marglr' : 0.5,
'margin' : 1.0,
'pagesh' : 1,
'pagesv' : 1,
'gvof' : 'ps',
@@ -482,10 +476,8 @@ class GraphVizOptions(ReportOptions.ReportOptions):
'dashedl' : ("=0/1","Whether to use dotted lines for non-birth relationships.",
["Do not use dotted lines","Use dotted lines"],
True),
'margtb' : ("=num","Top & bottom margins.",
"Floating point values, in cm"),
'marglr' : ("=num","Left & right margins.",
"Floating point values, in cm"),
'margin' : ("=num","Margin size.",
"Floating point value, in cm"),
'pagesh' : ("=num","Number of pages in horizontal direction.",
"Integer values"),
'pagesv' : ("=num","Number of pages in vertical direction.",
@@ -677,20 +669,14 @@ class GraphVizOptions(ReportOptions.ReportOptions):
"to parents and children."))
# Page options tab
tb_margin_adj = gtk.Adjustment(value=self.options_dict['margtb'],
lower=0.25, upper=100.0, step_incr=0.25)
lr_margin_adj = gtk.Adjustment(value=self.options_dict['marglr'],
lower=0.25, upper=100.0, step_incr=0.25)
margin_adj = gtk.Adjustment(value=self.options_dict['margin'],
lower=0.0, upper=10.0, step_incr=1.0)
self.tb_margin_sb = gtk.SpinButton(adjustment=tb_margin_adj, digits=2)
self.lr_margin_sb = gtk.SpinButton(adjustment=lr_margin_adj, digits=2)
self.margin_sb = gtk.SpinButton(adjustment=margin_adj, digits=1)
dialog.add_frame_option(_("Page Options"),
_("Top & Bottom Margins"),
self.tb_margin_sb)
dialog.add_frame_option(_("Page Options"),
_("Left & Right Margins"),
self.lr_margin_sb)
_("Margin size"),
self.margin_sb)
hpages_adj = gtk.Adjustment(value=self.options_dict['pagesh'],
lower=1, upper=25, step_incr=1)
@@ -723,8 +709,7 @@ class GraphVizOptions(ReportOptions.ReportOptions):
def parse_user_options(self,dialog):
self.options_dict['incdate'] = int(self.includedates_cb.get_active())
self.options_dict['url'] = int(self.includeurl_cb.get_active())
self.options_dict['margtb'] = self.tb_margin_sb.get_value()
self.options_dict['marglr'] = self.lr_margin_sb.get_value()
self.options_dict['margin'] = self.margin_sb.get_value()
self.options_dict['dashedl'] = int(self.adoptionsdashed_cb.get_active())
self.options_dict['pagesh'] = self.hpages_sb.get_value_as_int()
self.options_dict['pagesv'] = self.vpages_sb.get_value_as_int()