summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnathan Corgan <johnathan@corganlabs.com>2015-01-13 12:46:06 -0800
committerJohnathan Corgan <johnathan@corganlabs.com>2015-01-13 12:46:06 -0800
commit6c121388075c9d7624bef832a5dd835da73798cc (patch)
treeaa3111dde90a750b8d5c2402033dd7585ec0e782
parent65dbd67db55fd0b6456a9de025cfead699af527e (diff)
parentb307c892fb348ddb3613db33db4e874879185fde (diff)
Merge remote-tracking branch 'gnuradio-wg-grc/maint_grcwg' into maint
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
-rw-r--r--grc/base/Block.py9
-rw-r--r--grc/base/Port.py11
-rw-r--r--grc/blocks/gr_message_domain.xml1
-rw-r--r--grc/gui/Connection.py37
-rw-r--r--grc/python/Connection.py2
-rw-r--r--grc/python/Port.py1
-rw-r--r--grc/python/flow_graph.tmpl2
7 files changed, 25 insertions, 38 deletions
diff --git a/grc/base/Block.py b/grc/base/Block.py
index a8a699f29d..128cc5ecbe 100644
--- a/grc/base/Block.py
+++ b/grc/base/Block.py
@@ -187,14 +187,11 @@ class Block(Element):
def back_ofthe_bus(self, portlist):
- portlist.sort(key=lambda a: a.get_type() == 'bus');
+ portlist.sort(key=lambda p: p._type == 'bus')
def filter_bus_port(self, ports):
- buslist = [i for i in ports if i.get_type() == 'bus'];
- if len(buslist) == 0:
- return ports;
- else:
- return buslist;
+ buslist = [p for p in ports if p._type == 'bus']
+ return buslist or ports
def get_enabled(self):
"""
diff --git a/grc/base/Port.py b/grc/base/Port.py
index b393ba9600..61970893c0 100644
--- a/grc/base/Port.py
+++ b/grc/base/Port.py
@@ -40,7 +40,6 @@ class Port(Element):
self._domain = n['domain']
self._hide = n.find('hide') or ''
self._dir = dir
- self._type_evaluated = None # updated on rewrite()
self._hide_evaluated = False # updated on rewrite()
def validate(self):
@@ -58,13 +57,13 @@ class Port(Element):
def rewrite(self):
"""resolve dependencies in for type and hide"""
Element.rewrite(self)
- self._type_evaluated = self.get_parent().resolve_dependencies(self._type)
hide = self.get_parent().resolve_dependencies(self._hide).strip().lower()
self._hide_evaluated = False if hide in ('false', 'off', '0') else bool(hide)
# update domain if was deduced from (dynamic) port type
- if self._domain == GR_STREAM_DOMAIN and self._type_evaluated == "message":
+ type_ = self.get_type()
+ if self._domain == GR_STREAM_DOMAIN and type_ == "message":
self._domain = GR_MESSAGE_DOMAIN
- if self._domain == GR_MESSAGE_DOMAIN and self._type_evaluated != "message":
+ if self._domain == GR_MESSAGE_DOMAIN and type_ != "message":
self._domain = GR_STREAM_DOMAIN
def __str__(self):
@@ -92,9 +91,7 @@ class Port(Element):
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) \
- if self._type_evaluated is None else self._type_evaluated
+ def get_type(self): return self.get_parent().resolve_dependencies(self._type)
def get_domain(self): return self._domain
def get_hide(self): return self._hide_evaluated
diff --git a/grc/blocks/gr_message_domain.xml b/grc/blocks/gr_message_domain.xml
index c1eedb7c88..bc8add99ab 100644
--- a/grc/blocks/gr_message_domain.xml
+++ b/grc/blocks/gr_message_domain.xml
@@ -7,6 +7,7 @@
<domain>
<name>GR Message</name>
<key>gr_message</key>
+ <color>#000</color>
<multiple_sources>True</multiple_sources>
<connection>
<source_domain>gr_message</source_domain>
diff --git a/grc/gui/Connection.py b/grc/gui/Connection.py
index 84004f5af6..f075a18175 100644
--- a/grc/gui/Connection.py
+++ b/grc/gui/Connection.py
@@ -38,7 +38,7 @@ class Connection(Element):
def __init__(self):
Element.__init__(self)
self._color = Colors.CONNECTION_ENABLED_COLOR
- self._bg_color = Colors.CONNECTION_ENABLED_COLOR
+ self._bg_color = self._arrow_color = self._color
def get_coordinate(self):
"""
@@ -83,18 +83,16 @@ class Connection(Element):
]
source_domain = self.get_source().get_domain()
sink_domain = self.get_sink().get_domain()
- if source_domain == GR_MESSAGE_DOMAIN:
- self.line_attributes[1] = gtk.gdk.LINE_ON_OFF_DASH
- else:
- self.line_attributes[1] = gtk.gdk.LINE_DOUBLE_DASH
- if source_domain != sink_domain:
- self.line_attributes[0] = 2
- get_domain_color = lambda d: Colors.get_color((
- self.get_parent().get_parent().get_domain(d) or {}
- ).get('color') or Colors.DEFAULT_DOMAIN_COLOR_CODE)
- self._color = get_domain_color(source_domain)
- self._bg_color = get_domain_color(sink_domain)
-
+ self.line_attributes[0] = 2 if source_domain != sink_domain else 0
+ self.line_attributes[1] = gtk.gdk.LINE_DOUBLE_DASH \
+ if not source_domain == sink_domain == GR_MESSAGE_DOMAIN \
+ else gtk.gdk.LINE_ON_OFF_DASH
+ get_domain_color = lambda d: Colors.get_color((
+ self.get_parent().get_parent().get_domain(d) or {}
+ ).get('color') or Colors.DEFAULT_DOMAIN_COLOR_CODE)
+ self._color = get_domain_color(source_domain)
+ self._bg_color = get_domain_color(sink_domain)
+ self._arrow_color = self._bg_color if self.is_valid() else Colors.CONNECTION_ERROR_COLOR
self._update_after_move()
def _update_after_move(self):
@@ -164,20 +162,15 @@ class Connection(Element):
self._sink_coor = sink.get_coordinate()
self._source_coor = source.get_coordinate()
#draw
- border_color = (
- Colors.HIGHLIGHT_COLOR if self.is_highlighted() else
- Colors.CONNECTION_DISABLED_COLOR if not self.get_enabled() else
- self._color
- )
- bg_color = (
+ mod_color = lambda color: (
Colors.HIGHLIGHT_COLOR if self.is_highlighted() else
Colors.CONNECTION_DISABLED_COLOR if not self.get_enabled() else
- self._bg_color
+ color
)
- Element.draw(self, gc, window, border_color, bg_color)
+ Element.draw(self, gc, window, mod_color(self._color), mod_color(self._bg_color))
# draw arrow on sink port
try:
- gc.set_foreground(bg_color)
+ gc.set_foreground(mod_color(self._arrow_color))
gc.set_line_attributes(0, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_BUTT, gtk.gdk.JOIN_MITER)
window.draw_polygon(gc, True, self._arrow)
except:
diff --git a/grc/python/Connection.py b/grc/python/Connection.py
index 0a6cf5fa46..822876a0ae 100644
--- a/grc/python/Connection.py
+++ b/grc/python/Connection.py
@@ -38,8 +38,8 @@ class Connection(_Connection, _GUIConnection):
Validate the connections.
The ports must match in io size.
"""
+ _Connection.validate(self)
source_size = Constants.TYPE_TO_SIZEOF[self.get_source().get_type()] * self.get_source().get_vlen()
sink_size = Constants.TYPE_TO_SIZEOF[self.get_sink().get_type()] * self.get_sink().get_vlen()
if source_size != sink_size:
self.add_error_message('Source IO size "%s" does not match sink IO size "%s".'%(source_size, sink_size))
- _Connection.validate(self)
diff --git a/grc/python/Port.py b/grc/python/Port.py
index 4cd07a9721..765e1d7423 100644
--- a/grc/python/Port.py
+++ b/grc/python/Port.py
@@ -140,7 +140,6 @@ class Port(_Port, _GUIPort):
Handle the port cloning for virtual blocks.
"""
if self.is_type_empty():
- self._type_evaluated = None
try: #clone type and vlen
source = self.resolve_empty_type()
self._type = str(source.get_type())
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index d66c2581de..2526f087eb 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -211,7 +211,7 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])
#set global $sink = $con.get_sink()
##resolve virtual sources to the actual sources
#if $source.get_parent().is_virtual_source()
- #set $source = $source.resolve_virtual_source()
+ #set global $source = $source.resolve_virtual_source()
#end if
##do not generate connections with virtual sinks
#if not $sink.get_parent().is_virtual_sink()