summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
Diffstat (limited to 'grc')
-rw-r--r--grc/base/Block.py2
-rw-r--r--grc/base/FlowGraph.py2
-rw-r--r--grc/blocks/Makefile.am2
-rw-r--r--grc/blocks/blks2_dxpsk2_demod.xml145
-rw-r--r--grc/blocks/blks2_dxpsk2_mod.xml95
-rw-r--r--grc/blocks/blks2_dxpsk_demod.xml2
-rw-r--r--grc/blocks/blks2_dxpsk_mod.xml2
-rw-r--r--grc/blocks/block_tree.xml3
-rw-r--r--grc/blocks/pad_sink.xml15
-rw-r--r--grc/blocks/pad_source.xml16
-rw-r--r--grc/freedesktop/grc_setup_freedesktop.in9
-rw-r--r--grc/grc_gnuradio/usrp/dual_usrp.py2
-rw-r--r--grc/grc_gnuradio/usrp/simple_usrp.py2
-rw-r--r--grc/grc_gnuradio/wxgui/top_block_gui.py1
-rw-r--r--grc/gui/ActionHandler.py1
-rw-r--r--grc/gui/Block.py21
-rw-r--r--grc/gui/Dialogs.py1
-rw-r--r--grc/gui/Element.py3
-rw-r--r--grc/gui/FlowGraph.py1
-rw-r--r--grc/gui/Param.py36
-rw-r--r--grc/gui/Port.py13
-rw-r--r--grc/gui/Utils.py23
-rw-r--r--grc/python/Constants.py1
-rw-r--r--grc/python/FlowGraph.py36
-rw-r--r--grc/python/Param.py1
-rw-r--r--grc/python/convert_hier.py14
-rw-r--r--grc/python/flow_graph.tmpl18
27 files changed, 360 insertions, 107 deletions
diff --git a/grc/base/Block.py b/grc/base/Block.py
index b2015cc40..42eb6b3fb 100644
--- a/grc/base/Block.py
+++ b/grc/base/Block.py
@@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from . import odict
from Element import Element
-from Param import Param
-from Port import Port
from Cheetah.Template import Template
from UserDict import UserDict
diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py
index 7c51ef42a..b4ac8fc3a 100644
--- a/grc/base/FlowGraph.py
+++ b/grc/base/FlowGraph.py
@@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from . import odict
from Element import Element
-from Block import Block
-from Connection import Connection
from .. gui import Messages
class FlowGraph(Element):
diff --git a/grc/blocks/Makefile.am b/grc/blocks/Makefile.am
index e436cc764..9c91af543 100644
--- a/grc/blocks/Makefile.am
+++ b/grc/blocks/Makefile.am
@@ -34,6 +34,8 @@ dist_ourdata_DATA = \
blks2_cvsd_decode.xml \
blks2_dxpsk_demod.xml \
blks2_dxpsk_mod.xml \
+ blks2_dxpsk2_demod.xml \
+ blks2_dxpsk2_mod.xml \
blks2_error_rate.xml \
blks2_fm_deemph.xml \
blks2_fm_demod_cf.xml \
diff --git a/grc/blocks/blks2_dxpsk2_demod.xml b/grc/blocks/blks2_dxpsk2_demod.xml
new file mode 100644
index 000000000..ce8305c50
--- /dev/null
+++ b/grc/blocks/blks2_dxpsk2_demod.xml
@@ -0,0 +1,145 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##DPSK2 Demod - 2, 4
+###################################################
+ -->
+<block>
+ <name>DPSK2 Demod</name>
+ <key>blks2_dxpsk2_demod</key>
+ <import>from gnuradio import blks2</import>
+ <make>blks2.$(type)2_demod(
+ samples_per_symbol=$samples_per_symbol,
+ excess_bw=$excess_bw,
+ costas_alpha=$costas_alpha,
+ timing_alpha=$timing_alpha,
+ timing_max_dev=$timing_max_dev,
+ gray_code=$gray_code,
+ verbose=$verbose,
+ log=$log,
+ sync_out=$sync_out,
+)</make>
+ <callback>clock_recov.set_alpha($costas_alpha)</callback>
+ <callback>clock_recov.set_beta(0.25*$costas_alpha**2)</callback>
+ <callback>time_recov.set_alpha($timing_alpha)</callback>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>DBPSK</name>
+ <key>dbpsk</key>
+ </option>
+ <option>
+ <name>DQPSK</name>
+ <key>dqpsk</key>
+ </option>
+ </param>
+ <param>
+ <name>Samples/Symbol</name>
+ <key>samples_per_symbol</key>
+ <value>2</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Excess BW</name>
+ <key>excess_bw</key>
+ <value>0.35</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Costas Alpha</name>
+ <key>costas_alpha</key>
+ <value>0.175</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Timing Alpha</name>
+ <key>timing_alpha</key>
+ <value>0.100</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Timing Max Dev</name>
+ <key>timing_max_dev</key>
+ <value>1.5</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Omega Relative Limit</name>
+ <key>omega_relative_limit</key>
+ <value>0.005</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Gray Code</name>
+ <key>gray_code</key>
+ <value>True</value>
+ <type>bool</type>
+ <option>
+ <name>Yes</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>No</name>
+ <key>False</key>
+ </option>
+ </param>
+ <param>
+ <name>Verbose</name>
+ <key>verbose</key>
+ <value>False</value>
+ <type>bool</type>
+ <hide>#if str($verbose) == 'False' then 'part' else 'none'#</hide>
+ <option>
+ <name>On</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>Off</name>
+ <key>False</key>
+ </option>
+ </param>
+ <param>
+ <name>Logging</name>
+ <key>log</key>
+ <value>False</value>
+ <type>bool</type>
+ <hide>#if str($log) == 'False' then 'part' else 'none'#</hide>
+ <option>
+ <name>On</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>Off</name>
+ <key>False</key>
+ </option>
+ </param>
+ <param>
+ <name>Sync Out</name>
+ <key>sync_out</key>
+ <value>False</value>
+ <type>bool</type>
+ <option>
+ <name>On</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>Off</name>
+ <key>False</key>
+ </option>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>complex</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>byte</type>
+ </source>
+ <source>
+ <name>sync</name>
+ <type>complex</type>
+ <optional>1</optional>
+ </source>
+</block>
diff --git a/grc/blocks/blks2_dxpsk2_mod.xml b/grc/blocks/blks2_dxpsk2_mod.xml
new file mode 100644
index 000000000..bf292be17
--- /dev/null
+++ b/grc/blocks/blks2_dxpsk2_mod.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##DPSK2 Mod - 2, 4
+###################################################
+ -->
+<block>
+ <name>DPSK2 Mod</name>
+ <key>blks2_dxpsk2_mod</key>
+ <import>from gnuradio import blks2</import>
+ <make>blks2.$(type)2_mod(
+ samples_per_symbol=$samples_per_symbol,
+ excess_bw=$excess_bw,
+ gray_code=$gray_code,
+ verbose=$verbose,
+ log=$log,
+)</make>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>DBPSK</name>
+ <key>dbpsk</key>
+ </option>
+ <option>
+ <name>DQPSK</name>
+ <key>dqpsk</key>
+ </option>
+ </param>
+ <param>
+ <name>Samples/Symbol</name>
+ <key>samples_per_symbol</key>
+ <value>2</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Excess BW</name>
+ <key>excess_bw</key>
+ <value>0.35</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Gray Code</name>
+ <key>gray_code</key>
+ <value>True</value>
+ <type>bool</type>
+ <option>
+ <name>Yes</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>No</name>
+ <key>False</key>
+ </option>
+ </param>
+ <param>
+ <name>Verbose</name>
+ <key>verbose</key>
+ <value>False</value>
+ <type>bool</type>
+ <hide>#if str($verbose) == 'False' then 'part' else 'none'#</hide>
+ <option>
+ <name>On</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>Off</name>
+ <key>False</key>
+ </option>
+ </param>
+ <param>
+ <name>Logging</name>
+ <key>log</key>
+ <value>False</value>
+ <type>bool</type>
+ <hide>#if str($log) == 'False' then 'part' else 'none'#</hide>
+ <option>
+ <name>On</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>Off</name>
+ <key>False</key>
+ </option>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>complex</type>
+ </source>
+</block>
diff --git a/grc/blocks/blks2_dxpsk_demod.xml b/grc/blocks/blks2_dxpsk_demod.xml
index 4c13b3415..1c96b6cec 100644
--- a/grc/blocks/blks2_dxpsk_demod.xml
+++ b/grc/blocks/blks2_dxpsk_demod.xml
@@ -76,7 +76,7 @@
<name>Gray Code</name>
<key>gray_code</key>
<value>True</value>
- <type>enum</type>
+ <type>bool</type>
<option>
<name>Yes</name>
<key>True</key>
diff --git a/grc/blocks/blks2_dxpsk_mod.xml b/grc/blocks/blks2_dxpsk_mod.xml
index 28fd742fa..77505d8ad 100644
--- a/grc/blocks/blks2_dxpsk_mod.xml
+++ b/grc/blocks/blks2_dxpsk_mod.xml
@@ -48,7 +48,7 @@
<name>Gray Code</name>
<key>gray_code</key>
<value>True</value>
- <type>enum</type>
+ <type>bool</type>
<option>
<name>Yes</name>
<key>True</key>
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index fc074cb69..57703f6d6 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -225,6 +225,9 @@
<block>blks2_dxpsk_mod</block>
<block>blks2_dxpsk_demod</block>
+ <block>blks2_dxpsk2_mod</block>
+ <block>blks2_dxpsk2_demod</block>
+
<block>blks2_gmsk_mod</block>
<block>blks2_gmsk_demod</block>
diff --git a/grc/blocks/pad_sink.xml b/grc/blocks/pad_sink.xml
index 734526793..2e9495260 100644
--- a/grc/blocks/pad_sink.xml
+++ b/grc/blocks/pad_sink.xml
@@ -9,10 +9,10 @@
<key>pad_sink</key>
<make></make>
<param>
- <name>Num Inputs</name>
- <key>nports</key>
- <value>1</value>
- <type>int</type>
+ <name>Label</name>
+ <key>label</key>
+ <value>out</value>
+ <type>string</type>
</param>
<param>
<name>Input Type</name>
@@ -51,15 +51,14 @@
<type>int</type>
</param>
<check>$vlen &gt; 0</check>
- <check>0 &lt; $nports</check>
<sink>
<name>in</name>
<type>$type</type>
<vlen>$vlen</vlen>
- <nports>$nports</nports>
</sink>
<doc>
-The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block. \
-Limit one sink pad block per flow graph.
+The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block.
+
+Pad sink will be ordered alphabetically by their ids. The first pad sink will have an index of 0.
</doc>
</block>
diff --git a/grc/blocks/pad_source.xml b/grc/blocks/pad_source.xml
index f44d96238..7b2210cbb 100644
--- a/grc/blocks/pad_source.xml
+++ b/grc/blocks/pad_source.xml
@@ -9,10 +9,10 @@
<key>pad_source</key>
<make></make>
<param>
- <name>Num Outputs</name>
- <key>nports</key>
- <value>1</value>
- <type>int</type>
+ <name>Label</name>
+ <key>label</key>
+ <value>in</value>
+ <type>string</type>
</param>
<param>
<name>Output Type</name>
@@ -51,16 +51,14 @@
<type>int</type>
</param>
<check>$vlen &gt; 0</check>
- <check>0 &lt; $nports</check>
<source>
<name>out</name>
<type>$type</type>
<vlen>$vlen</vlen>
- <nports>$nports</nports>
</source>
<doc>
-The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block. \
-Limit one source pad block per flow graph. \
-The "pad sink id" will be ignored in this mode.
+The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block.
+
+Pad sources will be ordered alphabetically by their ids. The first pad source will have an index of 0.
</doc>
</block>
diff --git a/grc/freedesktop/grc_setup_freedesktop.in b/grc/freedesktop/grc_setup_freedesktop.in
index 33fc4e1ac..db6506452 100644
--- a/grc/freedesktop/grc_setup_freedesktop.in
+++ b/grc/freedesktop/grc_setup_freedesktop.in
@@ -20,11 +20,12 @@ case "$1" in
echo "Begin freedesktop install..."
for size in ${ICON_SIZES}; do \
echo "Install icon: ${size}x${size}"
- xdg-icon-resource install --context mimetypes --theme gnome --size ${size} ${SRCDIR}/grc-icon-${size}.png application-gnuradio-grc; \
- xdg-icon-resource install --context mimetypes --size ${size} ${SRCDIR}/grc-icon-${size}.png application-gnuradio-grc; \
- xdg-icon-resource install --context apps --theme gnome --size ${size} ${SRCDIR}/grc-icon-${size}.png gnuradio-grc; \
- xdg-icon-resource install --context apps --size ${size} ${SRCDIR}/grc-icon-${size}.png gnuradio-grc; \
+ xdg-icon-resource install --noupdate --context mimetypes --theme gnome --size ${size} ${SRCDIR}/grc-icon-${size}.png application-gnuradio-grc; \
+ xdg-icon-resource install --noupdate --context mimetypes --size ${size} ${SRCDIR}/grc-icon-${size}.png application-gnuradio-grc; \
+ xdg-icon-resource install --noupdate --context apps --theme gnome --size ${size} ${SRCDIR}/grc-icon-${size}.png gnuradio-grc; \
+ xdg-icon-resource install --noupdate --context apps --size ${size} ${SRCDIR}/grc-icon-${size}.png gnuradio-grc; \
done
+ xdg-icon-resource forceupdate
echo "Install mime type"
xdg-mime install ${SRCDIR}/gnuradio-grc.xml
echo "Install menu items"
diff --git a/grc/grc_gnuradio/usrp/dual_usrp.py b/grc/grc_gnuradio/usrp/dual_usrp.py
index 3692e1760..b26dbddd4 100644
--- a/grc/grc_gnuradio/usrp/dual_usrp.py
+++ b/grc/grc_gnuradio/usrp/dual_usrp.py
@@ -19,7 +19,7 @@
#
import common
-from gnuradio import gr, usrp
+from gnuradio import gr
####################################################################
# Dual USRP Source
diff --git a/grc/grc_gnuradio/usrp/simple_usrp.py b/grc/grc_gnuradio/usrp/simple_usrp.py
index fc4c75bf0..fb7a39570 100644
--- a/grc/grc_gnuradio/usrp/simple_usrp.py
+++ b/grc/grc_gnuradio/usrp/simple_usrp.py
@@ -19,7 +19,7 @@
#
import common
-from gnuradio import gr, usrp
+from gnuradio import gr
####################################################################
# Simple USRP Source
diff --git a/grc/grc_gnuradio/wxgui/top_block_gui.py b/grc/grc_gnuradio/wxgui/top_block_gui.py
index 998575897..333ccf1c1 100644
--- a/grc/grc_gnuradio/wxgui/top_block_gui.py
+++ b/grc/grc_gnuradio/wxgui/top_block_gui.py
@@ -19,7 +19,6 @@
#
import wx
-import sys, os
from gnuradio import gr
import panel
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index ee3e19a6c..108e23a23 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -29,7 +29,6 @@ import Preferences
from threading import Thread
import Messages
from .. base import ParseXML
-import random
from MainWindow import MainWindow
from PropsDialog import PropsDialog
import Dialogs
diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index 8c65bf06f..27143e070 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -29,6 +29,7 @@ from Constants import \
import pygtk
pygtk.require('2.0')
import gtk
+import pango
BLOCK_MARKUP_TMPL="""\
#set $foreground = $block.is_valid() and 'black' or 'red'
@@ -130,8 +131,11 @@ class Block(Element):
layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self))
self.label_width, self.label_height = layout.get_pixel_size()
#display the params
- for param in filter(lambda p: p.get_hide() not in ('all', 'part'), self.get_params()):
- layout = param.get_layout()
+ markups = [param.get_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')]
+ if markups:
+ layout = gtk.DrawingArea().create_pango_layout('')
+ layout.set_spacing(LABEL_SEPARATION*pango.SCALE)
+ layout.set_markup('\n'.join(markups))
layouts.append(layout)
w,h = layout.get_pixel_size()
self.label_width = max(w, self.label_width)
@@ -151,12 +155,11 @@ class Block(Element):
else: w_off = 0
pixmap.draw_layout(gc, w_off, h_off, layout)
h_off = h + h_off + LABEL_SEPARATION
- #create vertical and horizontal images
- self.horizontal_label = image = pixmap.get_image(0, 0, width, height)
+ #create vertical and horizontal pixmaps
+ self.horizontal_label = pixmap
if self.is_vertical():
- self.vertical_label = vimage = gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), height, width)
- for i in range(width):
- for j in range(height): vimage.put_pixel(j, width-i-1, image.get_pixel(i, j))
+ self.vertical_label = self.get_parent().new_pixmap(height, width)
+ Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
#calculate width and height needed
self.W = self.label_width + 2*BLOCK_LABEL_PADDING
self.H = max(*(
@@ -179,9 +182,9 @@ class Block(Element):
)
#draw label image
if self.is_horizontal():
- window.draw_image(gc, self.horizontal_label, 0, 0, x+BLOCK_LABEL_PADDING, y+(self.H-self.label_height)/2, -1, -1)
+ window.draw_drawable(gc, self.horizontal_label, 0, 0, x+BLOCK_LABEL_PADDING, y+(self.H-self.label_height)/2, -1, -1)
elif self.is_vertical():
- window.draw_image(gc, self.vertical_label, 0, 0, x+(self.H-self.label_height)/2, y+BLOCK_LABEL_PADDING, -1, -1)
+ 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(): port.draw(gc, window)
diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py
index af40f47c0..473c796af 100644
--- a/grc/gui/Dialogs.py
+++ b/grc/gui/Dialogs.py
@@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import pygtk
pygtk.require('2.0')
import gtk
-import Preferences
import Utils
class TextDisplay(gtk.TextView):
diff --git a/grc/gui/Element.py b/grc/gui/Element.py
index f0518ee12..e020c5caa 100644
--- a/grc/gui/Element.py
+++ b/grc/gui/Element.py
@@ -17,9 +17,6 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-import pygtk
-pygtk.require('2.0')
-import gtk
from Constants import LINE_SELECT_SENSITIVITY
from Constants import POSSIBLE_ROTATIONS
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 8feb171f1..5adecccc1 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -22,7 +22,6 @@ import Actions
import Colors
import Utils
from Element import Element
-from .. base import FlowGraph as _FlowGraph
import pygtk
pygtk.require('2.0')
import gtk
diff --git a/grc/gui/Param.py b/grc/gui/Param.py
index 4464a57ab..b3018dab2 100644
--- a/grc/gui/Param.py
+++ b/grc/gui/Param.py
@@ -38,6 +38,7 @@ class InputParam(gtk.HBox):
#connect events
self.connect('show', self._update_gui)
def set_color(self, color): pass
+ def set_tooltip_text(self, text): pass
def _update_gui(self, *args):
"""
@@ -51,8 +52,7 @@ class InputParam(gtk.HBox):
#set the color
self.set_color(self.param.get_color())
#set the tooltip
- if self.tp: self.tp.set_tip(
- self.entry,
+ self.set_tooltip_text(
Utils.parse_template(TIP_MARKUP_TMPL, param=self.param).strip(),
)
#show/hide
@@ -77,16 +77,13 @@ class EntryParam(InputParam):
def __init__(self, *args, **kwargs):
InputParam.__init__(self, *args, **kwargs)
- self.entry = input = gtk.Entry()
- input.set_text(self.param.get_value())
- input.connect('changed', self._handle_changed)
- self.pack_start(input, True)
- self.get_text = input.get_text
- #tool tip
- self.tp = gtk.Tooltips()
- self.tp.set_tip(self.entry, '')
- self.tp.enable()
- def set_color(self, color): self.entry.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
+ self._input = gtk.Entry()
+ self._input.set_text(self.param.get_value())
+ self._input.connect('changed', self._handle_changed)
+ self.pack_start(self._input, True)
+ def get_text(self): return self._input.get_text()
+ def set_color(self, color): self._input.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
+ def set_tooltip_text(self, text): self._input.set_tooltip_text(text)
class EnumParam(InputParam):
"""Provide an entry box for Enum types with a drop down menu."""
@@ -99,6 +96,7 @@ class EnumParam(InputParam):
self._input.connect('changed', self._handle_changed)
self.pack_start(self._input, False)
def get_text(self): return self.param.get_option_keys()[self._input.get_active()]
+ def set_tooltip_text(self, text): self._input.set_tooltip_text(text)
class EnumEntryParam(InputParam):
"""Provide an entry box and drop down menu for Raw Enum types."""
@@ -117,6 +115,10 @@ class EnumEntryParam(InputParam):
def get_text(self):
if self._input.get_active() == -1: return self._input.get_child().get_text()
return self.param.get_option_keys()[self._input.get_active()]
+ def set_tooltip_text(self, text):
+ if self._input.get_active() == -1: #custom entry
+ self._input.get_child().set_tooltip_text(text)
+ else: self._input.set_tooltip_text(text)
def set_color(self, color):
if self._input.get_active() == -1: #custom entry, use color
self._input.get_child().modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
@@ -163,11 +165,9 @@ class Param(Element):
if self.get_options(): return EnumEntryParam(self, *args, **kwargs)
return EntryParam(self, *args, **kwargs)
- def get_layout(self):
+ def get_markup(self):
"""
- Create a layout based on the current markup.
- @return the pango layout
+ Get the markup for this param.
+ @return a pango markup string
"""
- layout = gtk.DrawingArea().create_pango_layout('')
- layout.set_markup(Utils.parse_template(PARAM_MARKUP_TMPL, param=self))
- return layout
+ return Utils.parse_template(PARAM_MARKUP_TMPL, param=self)
diff --git a/grc/gui/Port.py b/grc/gui/Port.py
index 6763f6cbd..2896d04c1 100644
--- a/grc/gui/Port.py
+++ b/grc/gui/Port.py
@@ -97,12 +97,11 @@ class Port(Element):
gc.set_foreground(self._bg_color)
pixmap.draw_rectangle(gc, True, 0, 0, self.w, self.h)
pixmap.draw_layout(gc, 0, 0, layout)
- #create the images
- self.horizontal_label = image = pixmap.get_image(0, 0, self.w, self.h)
+ #create vertical and horizontal pixmaps
+ self.horizontal_label = pixmap
if self.is_vertical():
- self.vertical_label = vimage = gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), self.h, self.w)
- for i in range(self.w):
- for j in range(self.h): vimage.put_pixel(j, self.w-i-1, image.get_pixel(i, j))
+ self.vertical_label = self.get_parent().get_parent().new_pixmap(self.h, self.w)
+ Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
def draw(self, gc, window):
"""
@@ -117,9 +116,9 @@ class Port(Element):
X,Y = self.get_coordinate()
(x,y),(w,h) = self._areas_list[0] #use the first area's sizes to place the labels
if self.is_horizontal():
- window.draw_image(gc, self.horizontal_label, 0, 0, x+X+(self.W-self.w)/2, y+Y+(self.H-self.h)/2, -1, -1)
+ window.draw_drawable(gc, self.horizontal_label, 0, 0, x+X+(self.W-self.w)/2, y+Y+(self.H-self.h)/2, -1, -1)
elif self.is_vertical():
- window.draw_image(gc, self.vertical_label, 0, 0, x+X+(self.H-self.h)/2, y+Y+(self.W-self.w)/2, -1, -1)
+ window.draw_drawable(gc, self.vertical_label, 0, 0, x+X+(self.H-self.h)/2, y+Y+(self.W-self.w)/2, -1, -1)
def get_connector_coordinate(self):
"""
diff --git a/grc/gui/Utils.py b/grc/gui/Utils.py
index 83036a4b8..b5489d56e 100644
--- a/grc/gui/Utils.py
+++ b/grc/gui/Utils.py
@@ -19,8 +19,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from Constants import POSSIBLE_ROTATIONS
from Cheetah.Template import Template
+import pygtk
+pygtk.require('2.0')
+import gtk
import gobject
+def rotate_pixmap(gc, src_pixmap, dst_pixmap, angle=gtk.gdk.PIXBUF_ROTATE_COUNTERCLOCKWISE):
+ """
+ Load the destination pixmap with a rotated version of the source pixmap.
+ The source pixmap will be loaded into a pixbuf, rotated, and drawn to the destination pixmap.
+ The pixbuf is a client-side drawable, where a pixmap is a server-side drawable.
+ @param gc the graphics context
+ @param src_pixmap the source pixmap
+ @param dst_pixmap the destination pixmap
+ @param angle the angle to rotate by
+ """
+ width, height = src_pixmap.get_size()
+ pixbuf = gtk.gdk.Pixbuf(
+ colorspace=gtk.gdk.COLORSPACE_RGB,
+ has_alpha=False, bits_per_sample=8,
+ width=width, height=height,
+ )
+ pixbuf.get_from_drawable(src_pixmap, src_pixmap.get_colormap(), 0, 0, 0, 0, -1, -1)
+ pixbuf = pixbuf.rotate_simple(angle)
+ dst_pixmap.draw_pixbuf(gc, pixbuf, 0, 0, 0, 0)
+
def get_rotated_coordinate(coor, rotation):
"""
Rotate the coordinate by the given rotation.
diff --git a/grc/python/Constants.py b/grc/python/Constants.py
index 439a52420..e661c3927 100644
--- a/grc/python/Constants.py
+++ b/grc/python/Constants.py
@@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
import os
-import sys
import stat
from gnuradio import gr
diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py
index 4dd18a81f..b2d406bbd 100644
--- a/grc/python/FlowGraph.py
+++ b/grc/python/FlowGraph.py
@@ -20,8 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import expr_utils
from .. base.FlowGraph import FlowGraph as _FlowGraph
from .. gui.FlowGraph import FlowGraph as _GUIFlowGraph
-from Block import Block
-from Connection import Connection
import re
_variable_matcher = re.compile('^(variable\w*)$')
@@ -50,44 +48,36 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
#return from cache
return self._eval_cache[my_hash]
- def _get_io_signature(self, pad_key):
+ def _get_io_signaturev(self, pad_key):
"""
- Get an io signature for this flow graph.
+ Get a list of io signatures for this flow graph.
The pad key determines the directionality of the io signature.
@param pad_key a string of pad_source or pad_sink
- @return a dict with: type, nports, vlen, size
+ @return a list of dicts with: type, label, vlen, size
"""
pads = filter(lambda b: b.get_key() == pad_key, self.get_enabled_blocks())
- if not pads: return {
- 'nports': '0',
- 'type': '',
- 'vlen': '0',
- 'size': '0',
- }
- pad = pads[0] #take only the first, user should not have more than 1
+ sorted_pads = sorted(pads, lambda x, y: cmp(x.get_id(), y.get_id()))
#load io signature
- return {
- 'nports': str(pad.get_param('nports').get_evaluated()),
+ return [{
+ 'label': str(pad.get_param('label').get_evaluated()),
'type': str(pad.get_param('type').get_evaluated()),
'vlen': str(pad.get_param('vlen').get_evaluated()),
'size': pad.get_param('type').get_opt('size'),
- }
+ } for pad in sorted_pads]
- def get_input_signature(self):
+ def get_input_signaturev(self):
"""
Get the io signature for the input side of this flow graph.
- The io signature with be "0", "0" if no pad source is present.
- @return a string tuple of type, num_ports, port_size
+ @return a list of io signature structures
"""
- return self._get_io_signature('pad_source')
+ return self._get_io_signaturev('pad_source')
- def get_output_signature(self):
+ def get_output_signaturev(self):
"""
Get the io signature for the output side of this flow graph.
- The io signature with be "0", "0" if no pad sink is present.
- @return a string tuple of type, num_ports, port_size
+ @return a list of io signature structures
"""
- return self._get_io_signature('pad_sink')
+ return self._get_io_signaturev('pad_sink')
def get_imports(self):
"""
diff --git a/grc/python/Param.py b/grc/python/Param.py
index 81fb6ba7a..febb112ad 100644
--- a/grc/python/Param.py
+++ b/grc/python/Param.py
@@ -17,7 +17,6 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-import expr_utils
from .. base.Param import Param as _Param
from .. gui.Param import Param as _GUIParam
from .. gui.Param import EntryParam
diff --git a/grc/python/convert_hier.py b/grc/python/convert_hier.py
index bdafbcbc1..befddccea 100644
--- a/grc/python/convert_hier.py
+++ b/grc/python/convert_hier.py
@@ -23,8 +23,8 @@ from .. base import odict
def convert_hier(flow_graph, python_file):
#extract info from the flow graph
- input_sig = flow_graph.get_input_signature()
- output_sig = flow_graph.get_output_signature()
+ input_sigs = flow_graph.get_input_signaturev()
+ output_sigs = flow_graph.get_output_signaturev()
parameters = flow_graph.get_parameters()
block_key = flow_graph.get_option('id')
block_name = flow_graph.get_option('title')
@@ -56,20 +56,18 @@ def convert_hier(flow_graph, python_file):
params_n.append(param_n)
block_n['param'] = params_n
#sink data
- if int(input_sig['nports']):
+ for input_sig in input_sigs:
sink_n = odict()
- sink_n['name'] = 'in'
+ sink_n['name'] = input_sig['label']
sink_n['type'] = input_sig['type']
sink_n['vlen'] = input_sig['vlen']
- sink_n['nports'] = input_sig['nports']
block_n['sink'] = sink_n
#source data
- if int(output_sig['nports']):
+ for output_sig in output_sigs:
source_n = odict()
- source_n['name'] = 'out'
+ source_n['name'] = output_sig['label']
source_n['type'] = output_sig['type']
source_n['vlen'] = output_sig['vlen']
- source_n['nports'] = output_sig['nports']
block_n['source'] = source_n
#doc data
block_n['doc'] = "%s\n%s\n%s"%(block_author, block_desc, python_file)
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index ab764006c..a1a9308aa 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -65,15 +65,25 @@ class $(class_name)(gr.top_block):
def __init__($param_str):
gr.top_block.__init__(self, "$title")
#elif $generate_options == 'hb'
- #set $in_sig = $flow_graph.get_input_signature()
- #set $out_sig = $flow_graph.get_output_signature()
+ #set $in_sigs = $flow_graph.get_input_signaturev()
+ #set $out_sigs = $flow_graph.get_output_signaturev()
class $(class_name)(gr.hier_block2):
+#def make_io_sig($io_sigs)
+ #set $size_strs = ['%s*%s'%(io_sig['size'], io_sig['vlen']) for io_sig in $io_sigs]
+ #if len($io_sigs) == 0
+gr.io_signature(0, 0, 0)#slurp
+ #elif len($io_sigs) == 1
+gr.io_signature(1, 1, $size_strs[0])#slurp
+ #else
+gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])#slurp
+ #end if
+#end def
def __init__($param_str):
gr.hier_block2.__init__(
self, "$title",
- gr.io_signature($in_sig.nports, $in_sig.nports, $in_sig.size*$in_sig.vlen),
- gr.io_signature($out_sig.nports, $out_sig.nports, $out_sig.size*$out_sig.vlen),
+ $make_io_sig($in_sigs),
+ $make_io_sig($out_sigs),
)
#end if
########################################################