[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 03/37: grc: allow blocks to dynamically hid
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 03/37: grc: allow blocks to dynamically hide some of their ports |
Date: |
Thu, 17 Jul 2014 20:23:39 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 831d05eb283e1ac4decb312c990cba089cdca316
Author: Sebastian Koslowski <address@hidden>
Date: Sat Jul 5 21:28:15 2014 +0200
grc: allow blocks to dynamically hide some of their ports
---
grc/base/Port.py | 31 ++++++++++++++++---------------
grc/gui/Block.py | 22 +++++++++++++++-------
grc/gui/Port.py | 2 +-
grc/python/block.dtd | 4 ++--
4 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/grc/base/Port.py b/grc/base/Port.py
index b7de530..0f81dfc 100644
--- a/grc/base/Port.py
+++ b/grc/base/Port.py
@@ -36,6 +36,7 @@ class Port(Element):
self._name = n['name']
self._key = n['key']
self._type = n['type']
+ self._hide = n.find('hide') or ''
self._dir = dir
def validate(self):
@@ -65,15 +66,17 @@ class Port(Element):
def get_name(self):
number = ''
if self.get_type() == 'bus':
- busses = filter(lambda a: a._dir == self._dir,
self.get_parent().get_ports_gui());
-
- number = str(busses.index(self)) + '#' +
str(len(self.get_associated_ports()));
+ busses = filter(lambda a: a._dir == self._dir,
self.get_parent().get_ports_gui())
+ number = str(busses.index(self)) + '#' +
str(len(self.get_associated_ports()))
return self._name + number
def get_key(self): return self._key
def is_sink(self): return self._dir == 'sink'
def is_source(self): return self._dir == 'source'
def get_type(self): return
self.get_parent().resolve_dependencies(self._type)
+ def get_hide(self):
+ value =
self.get_parent().resolve_dependencies(self._hide).strip().lower()
+ return False if value in ('false', 'off', '0') else bool(value)
def get_connections(self):
"""
@@ -97,20 +100,18 @@ class Port(Element):
def get_associated_ports(self):
if not self.get_type() == 'bus':
- return [self];
+ return [self]
else:
if self.is_source():
- get_p = self.get_parent().get_sources;
- bus_structure =
self.get_parent().current_bus_structure['source'];
- direc = 'source'
+ get_ports = self.get_parent().get_sources
+ bus_structure =
self.get_parent().current_bus_structure['source']
else:
- get_p = self.get_parent().get_sinks;
- bus_structure =
self.get_parent().current_bus_structure['sink'];
- direc = 'sink'
+ get_ports = self.get_parent().get_sinks
+ bus_structure = self.get_parent().current_bus_structure['sink']
- ports = [i for i in get_p() if not i.get_type() == 'bus'];
+ ports = [i for i in get_ports() if not i.get_type() == 'bus']
if bus_structure:
- busses = [i for i in get_p() if i.get_type() == 'bus'];
- bus_index = busses.index(self);
- ports = filter(lambda a: ports.index(a) in
bus_structure[bus_index], ports);
- return ports;
+ busses = [i for i in get_ports() if i.get_type() == 'bus']
+ bus_index = busses.index(self)
+ ports = filter(lambda a: ports.index(a) in
bus_structure[bus_index], ports)
+ return ports
diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index b2b3912..e8a253a 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -175,12 +175,19 @@ class Block(Element):
#calculate width and height needed
self.W = self.label_width + 2*BLOCK_LABEL_PADDING
self.H = max(*(
- [self.label_height+2*BLOCK_LABEL_PADDING] +
[2*PORT_BORDER_SEPARATION + \
- sum([port.H + PORT_SEPARATION for port in ports]) - PORT_SEPARATION
- for ports in (self.get_sources_gui(), self.get_sinks_gui())] +
- [4*PORT_BORDER_SEPARATION + \
- sum([(port.H) + PORT_SEPARATION for port in ports]) -
PORT_SEPARATION
- for ports in ([i for i in self.get_sources_gui() if i.get_type()
== 'bus'], [i for i in self.get_sinks_gui() if i.get_type() == 'bus'])]
+ [ # labels
+ self.label_height + 2 * BLOCK_LABEL_PADDING
+ ] +
+ [ # ports
+ 2 * PORT_BORDER_SEPARATION +
+ sum([port.H + PORT_SEPARATION for port in ports if not
port.get_hide()]) - PORT_SEPARATION
+ for ports in (self.get_sources_gui(), self.get_sinks_gui())
+ ] +
+ [ # bus ports only
+ 4 * PORT_BORDER_SEPARATION +
+ sum([port.H + PORT_SEPARATION for port in ports if
port.get_type() == 'bus']) - PORT_SEPARATION
+ for ports in (self.get_sources_gui(), self.get_sinks_gui())
+ ]
))
def draw(self, gc, window):
@@ -205,7 +212,8 @@ class Block(Element):
window.draw_drawable(gc, self.vertical_label, 0, 0,
x+(self.H-self.label_height)/2, y+BLOCK_LABEL_PADDING, -1, -1)
#draw ports
for port in self.get_ports_gui():
- port.draw(gc, window)
+ if not port.get_hide():
+ port.draw(gc, window)
def what_is_selected(self, coor, coor_m=None):
"""
diff --git a/grc/gui/Port.py b/grc/gui/Port.py
index e542797..6b92c40 100644
--- a/grc/gui/Port.py
+++ b/grc/gui/Port.py
@@ -59,7 +59,7 @@ class Port(Element):
if hasattr(self, '_connector_length'):
del self._connector_length;
return
- length = len(ports)
+ length = len(filter(lambda p: not p.get_hide(), ports))
#reverse the order of ports for these rotations
if rotation in (180, 270): index = length-index-1
offset = (self.get_parent().H - length*self.H -
(length-1)*PORT_SEPARATION)/2
diff --git a/grc/python/block.dtd b/grc/python/block.dtd
index 18e53fd..263df44 100644
--- a/grc/python/block.dtd
+++ b/grc/python/block.dtd
@@ -32,8 +32,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
<!ELEMENT param_tab_order (tab+)>
<!ELEMENT param (base_key?, name, key, value?, type?, hide?, option*, tab?)>
<!ELEMENT option (name, key, opt*)>
-<!ELEMENT sink (name, type, vlen?, nports?, optional?)>
-<!ELEMENT source (name, type, vlen?, nports?, optional?)>
+<!ELEMENT sink (name, type, vlen?, nports?, optional?, hide?)>
+<!ELEMENT source (name, type, vlen?, nports?, optional?, hide?)>
<!--
Bottom level elements.
Character data only.
- [Commit-gnuradio] [gnuradio] branch master updated (2bb2b31 -> 001ab47), git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 08/37: uhd: Added more type checking and flexibility to commands and tags, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 07/37: uhd: Added GRC bindings for command interface, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 02/37: digital: using new var_value for constellation variables, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 01/37: grc: design time values for object-like variables, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 04/37: uhd: Updated docs, in particular for the command interface, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 03/37: grc: allow blocks to dynamically hide some of their ports,
git <=
- [Commit-gnuradio] [gnuradio] 10/37: uhd: Added checks for lock sensors., git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 17/37: qtgui: allows users to set title and unit of Y axis for qt time plotter., git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 05/37: uhd: Added command interface to uhd source, modified command syntax, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 16/37: qtgui: adding ability to set grid on/off from grc properties dialog boxes for all qtgui sinks except the "sink" which doesn't support this., git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 12/37: Merge remote-tracking branch 'gnuradio-wg-grc/grc_variable_blocks', git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 22/37: Merge remote-tracking branch 'gnuradio-wg-grc/grc_port_view_options', git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 09/37: uhd: Added example for re-tuning through messages, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 06/37: uhd: Refactored common stuff from usrp sink and source, git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 23/37: qtgui: time raster display updates., git, 2014/07/17
- [Commit-gnuradio] [gnuradio] 11/37: build: missed gnuradio-uhd in static libs build., git, 2014/07/17