commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 76/101: grc: gtk3: calculate flowgraph canv


From: git
Subject: [Commit-gnuradio] [gnuradio] 76/101: grc: gtk3: calculate flowgraph canvas size
Date: Thu, 16 Mar 2017 14:58:10 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch python3
in repository gnuradio.

commit eeea99b45c0a0dccd935dc5203b71e0adf1430fe
Author: Sebastian Koslowski <address@hidden>
Date:   Tue Aug 30 16:27:31 2016 +0200

    grc: gtk3: calculate flowgraph canvas size
---
 grc/gui/Block.py     | 10 ++++++++++
 grc/gui/Element.py   |  9 +++++++++
 grc/gui/FlowGraph.py | 16 ++++++++++------
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index 4b6c5b8..b37bec6 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -311,6 +311,16 @@ class Block(CoreBlock, Element):
         PangoCairo.show_layout(cr, self._comment_layout)
         cr.restore()
 
+    @property
+    def extend(self):
+        extend = Element.extend.fget(self)
+        x, y = self.coordinate
+        for port in self.active_ports():
+            extend = (min_or_max(xy, offset + p_xy) for offset, min_or_max, 
xy, p_xy in zip(
+                (x, y, x, y), (min, min, max, max), extend, port.extend
+            ))
+        return tuple(extend)
+
     ##############################################
     # Controller Modify
     ##############################################
diff --git a/grc/gui/Element.py b/grc/gui/Element.py
index 8418bef..17cd6dd 100644
--- a/grc/gui/Element.py
+++ b/grc/gui/Element.py
@@ -168,6 +168,15 @@ class Element(object):
                 if x <= x1 <= x_m and y <= y1 <= y_m:
                     return self
 
+    @property
+    def extend(self):
+        x_min, y_min = x_max, y_max = self.coordinate
+        x_min += min(x for x, y in self._bounding_points)
+        y_min += min(y for x, y in self._bounding_points)
+        x_max += max(x for x, y in self._bounding_points)
+        y_max += max(y for x, y in self._bounding_points)
+        return x_min, y_min, x_max, y_max
+
     def mouse_over(self):
         pass
 
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index f082e4f..df8e668 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -742,9 +742,13 @@ class FlowGraph(CoreFlowgraph, Element):
         self.drawing_area.queue_draw()
 
     def get_max_coords(self, initial=(0, 0)):
-        w, h = initial
-        for block in self.blocks:
-            x, y = block.coordinate
-            w = max(w, x + block.width)
-            h = max(h, y + block.height)
-        return w, h
+        return tuple(max(i, e) for i, e in zip(initial, self.extend[2:]))
+
+    @property
+    def extend(self):
+        extend = 100000, 100000, 0, 0
+        for element in self._elements_to_draw:
+            extend = (min_or_max(xy, e_xy) for min_or_max, xy, e_xy in zip(
+                (min, min, max, max), extend, element.extend
+            ))
+        return tuple(extend)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]