summaryrefslogtreecommitdiff
path: root/grc/core
diff options
context:
space:
mode:
Diffstat (limited to 'grc/core')
-rw-r--r--grc/core/Constants.py56
-rw-r--r--grc/core/Platform.py3
-rw-r--r--grc/core/Port.py26
3 files changed, 24 insertions, 61 deletions
diff --git a/grc/core/Constants.py b/grc/core/Constants.py
index 992d5e7d83..99531487fd 100644
--- a/grc/core/Constants.py
+++ b/grc/core/Constants.py
@@ -99,41 +99,33 @@ GRC_COLOR_GREY = '#BDBDBD'
GRC_COLOR_WHITE = '#FFFFFF'
CORE_TYPES = ( # name, key, sizeof, color
- ('Complex Float 64', 'fc64', 16, GRC_COLOR_BROWN),
- ('Complex Float 32', 'fc32', 8, GRC_COLOR_BLUE),
- ('Complex Integer 64', 'sc64', 16, GRC_COLOR_LIGHT_GREEN),
- ('Complex Integer 32', 'sc32', 8, GRC_COLOR_GREEN),
- ('Complex Integer 16', 'sc16', 4, GRC_COLOR_AMBER),
- ('Complex Integer 8', 'sc8', 2, GRC_COLOR_PURPLE),
- ('Float 64', 'f64', 8, GRC_COLOR_CYAN),
- ('Float 32', 'f32', 4, GRC_COLOR_ORANGE),
- ('Integer 64', 's64', 8, GRC_COLOR_LIME),
- ('Integer 32', 's32', 4, GRC_COLOR_TEAL),
- ('Integer 16', 's16', 2, GRC_COLOR_YELLOW),
- ('Integer 8', 's8', 1, GRC_COLOR_PURPLE_A400),
- ('Bits (unpacked byte)', 'bit', 1, GRC_COLOR_PURPLE_A100),
- ('Message Queue', 'msg', 0, GRC_COLOR_DARK_GREY),
- ('Async Message', 'message', 0, GRC_COLOR_GREY),
- ('Bus Connection', 'bus', 0, GRC_COLOR_WHITE),
- ('Wildcard', '', 0, GRC_COLOR_WHITE),
+ ('Complex Float 64', 'fc64', 16, GRC_COLOR_BROWN),
+ ('Complex Float 32', 'fc32', 8, GRC_COLOR_BLUE),
+ ('Complex Integer 64', 'sc64', 16, GRC_COLOR_LIGHT_GREEN),
+ ('Complex Integer 32', 'sc32', 8, GRC_COLOR_GREEN),
+ ('Complex Integer 16', 'sc16', 4, GRC_COLOR_AMBER),
+ ('Complex Integer 8', 'sc8', 2, GRC_COLOR_PURPLE),
+ ('Float 64', 'f64', 8, GRC_COLOR_CYAN),
+ ('Float 32', 'f32', 4, GRC_COLOR_ORANGE),
+ ('Integer 64', 's64', 8, GRC_COLOR_LIME),
+ ('Integer 32', 's32', 4, GRC_COLOR_TEAL),
+ ('Integer 16', 's16', 2, GRC_COLOR_YELLOW),
+ ('Integer 8', 's8', 1, GRC_COLOR_PURPLE_A400),
+ ('Bits (unpacked byte)', 'bit', 1, GRC_COLOR_PURPLE_A100),
+ ('Message Queue', 'msg', 0, GRC_COLOR_DARK_GREY),
+ ('Async Message', 'message', 0, GRC_COLOR_GREY),
+ ('Bus Connection', 'bus', 0, GRC_COLOR_WHITE),
+ ('Wildcard', '', 0, GRC_COLOR_WHITE),
)
ALIAS_TYPES = {
'complex': (8, GRC_COLOR_BLUE),
- 'float': (4, GRC_COLOR_ORANGE),
- 'int': (4, GRC_COLOR_TEAL),
- 'short': (2, GRC_COLOR_YELLOW),
- 'byte': (1, GRC_COLOR_PURPLE_A400),
- 'bits': (1, GRC_COLOR_PURPLE_A100),
+ 'float': (4, GRC_COLOR_ORANGE),
+ 'int': (4, GRC_COLOR_TEAL),
+ 'short': (2, GRC_COLOR_YELLOW),
+ 'byte': (1, GRC_COLOR_PURPLE_A400),
+ 'bits': (1, GRC_COLOR_PURPLE_A100),
}
-TYPE_TO_COLOR = dict()
-TYPE_TO_SIZEOF = dict()
-
-for name, key, sizeof, color in CORE_TYPES:
- TYPE_TO_COLOR[key] = color
- TYPE_TO_SIZEOF[key] = sizeof
-
-for key, (sizeof, color) in six.iteritems(ALIAS_TYPES):
- TYPE_TO_COLOR[key] = color
- TYPE_TO_SIZEOF[key] = sizeof
+TYPE_TO_SIZEOF = {key: sizeof for name, key, sizeof, color in CORE_TYPES}
+TYPE_TO_SIZEOF.update((key, sizeof) for key, (sizeof, _) in ALIAS_TYPES.items())
diff --git a/grc/core/Platform.py b/grc/core/Platform.py
index be7b60ca59..844693d14b 100644
--- a/grc/core/Platform.py
+++ b/grc/core/Platform.py
@@ -310,6 +310,3 @@ class Platform(Element):
def get_new_block(self, flow_graph, key):
return self.Block(flow_graph, n=self._blocks_n[key])
-
- def get_colors(self):
- return [(name, color) for name, key, sizeof, color in Constants.CORE_TYPES]
diff --git a/grc/core/Port.py b/grc/core/Port.py
index 9a33c5c506..4ba516d5fe 100644
--- a/grc/core/Port.py
+++ b/grc/core/Port.py
@@ -263,32 +263,6 @@ class Port(Element):
def get_optional(self):
return bool(self._optional)
- def get_color(self):
- """
- Get the color that represents this port's type.
- Codes differ for ports where the vec length is 1 or greater than 1.
-
- Returns:
- a hex color code.
- """
- try:
- color = Constants.TYPE_TO_COLOR[self.get_type()]
- vlen = self.get_vlen()
- if vlen == 1:
- return color
- color_val = int(color[1:], 16)
- r = (color_val >> 16) & 0xff
- g = (color_val >> 8) & 0xff
- b = (color_val >> 0) & 0xff
- dark = (0, 0, 30, 50, 70)[min(4, vlen)]
- r = max(r-dark, 0)
- g = max(g-dark, 0)
- b = max(b-dark, 0)
- # TODO: Change this to .format()
- return '#%.2x%.2x%.2x' % (r, g, b)
- except:
- return '#FFFFFF'
-
def get_clones(self):
"""
Get the clones of this master port (nports > 1)