[pypy-svn] r60018 - pypy/trunk/dotviewer
arigo at codespeak.net
arigo at codespeak.net
Thu Nov 20 13:49:16 CET 2008
Author: arigo
Date: Thu Nov 20 13:49:15 2008
New Revision: 60018
Modified:
pypy/trunk/dotviewer/drawgraph.py
Log:
We don't know when the list of vertices in the right
or reversed order. Reverse it whe we detect it is the case.
Modified: pypy/trunk/dotviewer/drawgraph.py
==============================================================================
--- pypy/trunk/dotviewer/drawgraph.py (original)
+++ pypy/trunk/dotviewer/drawgraph.py Thu Nov 20 13:49:15 2008
@@ -167,8 +167,16 @@
def arrowhead(self):
result = self.cachedarrowhead
if result is None:
- bottom_up = self.points[0][1] > self.points[-1][1]
- if (self.tail.y > self.head.y) != bottom_up: # reversed edge
+ # we don't know if the list of points is in the right order
+ # or not :-( try to guess...
+ def dist(node, pt):
+ return abs(node.x - pt[0]) + abs(node.y - pt[1])
+
+ error_if_direct = (dist(self.head, self.points[-1]) +
+ dist(self.tail, self.points[0]))
+ error_if_reversed = (dist(self.tail, self.points[-1]) +
+ dist(self.head, self.points[0]))
+ if error_if_direct > error_if_reversed: # reversed edge
head = 0
dir = 1
else:
More information about the Pypy-commit
mailing list