diff --git a/range.py b/range.py index b25c961..63b4194 100644 --- a/range.py +++ b/range.py @@ -18,6 +18,7 @@ class Range: self.description = description self.values = values self.dependsOn = dependsOn + self.lastValueY = -1 @property def bits(self) -> int: diff --git a/renderer.py b/renderer.py index d755d5a..9bf33e5 100644 --- a/renderer.py +++ b/renderer.py @@ -193,8 +193,13 @@ class Renderer: rWidth = range_.bits * bitW self.drawUnderbracket(rStartX, rStartX + rWidth, bitsY) - prevY = bitsY + bitH * 1.5 dependRange = struct.ranges[range_.dependsOn] + prevRangeY = bitsY + bitH * 1.5 + if dependRange.lastValueY == -1: + prevDependY = bitsY + bitH * 1.5 + else: + prevDependY = dependRange.lastValueY + dependStartI = struct.bits - dependRange.end - 1 dependStartX = bitsX + dependStartI * bitW dependWidth = dependRange.bits * bitW @@ -202,7 +207,7 @@ class Renderer: self.drawUnderbracket(dependStartX, dependStartX + dependWidth, bitsY) for val, data in sorted(range_.values.items(), key=lambda vd: vd[0]): - self.drawArrow(dependMid, prevY, dependMid, descY - arrowMargin) + self.drawArrow(dependMid, prevDependY, dependMid, descY - arrowMargin) valRanges = {} for i in range(dependRange.bits): @@ -234,11 +239,13 @@ class Renderer: self.drawArrow(x1, y, x2, y, data["description"]) self.drawArrow(rStartX + rWidth - bitW, - prevY, + prevRangeY, rStartX + rWidth - bitW, descY + bitH - arrowMargin) - prevY = descY + bitH*2 + arrowMargin + prevDependY = descY + bitH*2 + arrowMargin + prevRangeY =prevDependY + dependRange.lastValueY = prevDependY descY = self.drawStructure(structures[data["structure"]], structures, rStartX, descY) return (descX, descY)