From f31caf1ea4df40d000e2669b2655e5de40a9e495 Mon Sep 17 00:00:00 2001 From: Jonathan Biegert Date: Sun, 17 Sep 2017 17:20:23 -0700 Subject: [PATCH] enable Graphviz node port selection, optionable (p.r. 456) This enables the headport and tailport attributes for all edges in the Graphviz file. The default (off) value makes the arrows between persons and/or family nodes attach their ends to the respective node at any position. When this option is selected, the position facing the node on the other side of the arrow is always chosen. --- gramps/gen/plug/docgen/graphdoc.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gramps/gen/plug/docgen/graphdoc.py b/gramps/gen/plug/docgen/graphdoc.py index 694812168..562ee29b1 100644 --- a/gramps/gen/plug/docgen/graphdoc.py +++ b/gramps/gen/plug/docgen/graphdoc.py @@ -8,6 +8,7 @@ # Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2009 Benny Malengier # Copyright (C) 2009 Gary Burton +# Copyright (C) 2017 Jonathan Biegert # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -71,6 +72,11 @@ _RANKDIR = [ { 'name' : _("Vertical (↓)"), 'value' : "TB" }, { 'name' : _("Horizontal (→)"), 'value' : "LR" }, { 'name' : _("Horizontal (←)"), 'value' : "RL" } ] +_NODE_PORTS = { "TB" : ("n", "s"), + "BT" : ("s", "n"), + "LR" : ("w", "e"), + "RL" : ("e", "w") } + _PAGEDIR = [ { 'name' : _("Bottom, left"), 'value' :"BL" }, { 'name' : _("Bottom, right"), 'value' :"BR" }, { 'name' : _("Top, left"), 'value' :"TL" }, @@ -185,6 +191,10 @@ class GVOptions: spline.set_help(_("How the lines between objects will be drawn.")) menu.add_option(category, "spline", spline) + node_ports = BooleanOption(_("Alternate line attachment"), False) + node_ports.set_help(_("Whether lines attach to nodes differently")) + menu.add_option(category, "node_ports", node_ports) + # the page direction option only makes sense when the # number of horizontal and/or vertical pages is > 1, # so we need to remember these 3 controls for later @@ -410,6 +420,7 @@ class GVDocBase(BaseDoc, GVDoc): self.vpages = get_value('v_pages') self.usesubgraphs = get_value('usesubgraphs') self.spline = get_value('spline') + self.node_ports = get_value('node_ports') paper_size = paper_style.get_size() @@ -458,6 +469,9 @@ class GVDocBase(BaseDoc, GVDoc): '\n' + ' edge [len=0.5 style=solid fontsize=%d];\n' % self.fontsize ) + if self.node_ports: + self.write(' edge [headport=%s tailport=%s];\n' + % _NODE_PORTS[self.rankdir]) if self.fontfamily: self.write( ' node [style=filled fontname="%s" fontsize=%d];\n' % ( self.fontfamily, self.fontsize ) )