summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Blum2010-04-05 17:25:39 -0700
committerJosh Blum2010-04-05 17:25:39 -0700
commit5d7b2c44396ef6991b049d2d15ebf5b822690961 (patch)
tree35f6c0454af877d2051e440f99161b496e9bcc98
parent8dfa110cf286db709a503adafc296a8b23225645 (diff)
parent1ae689ff9238dcffbf65881b8ca03aa8df3844aa (diff)
downloadgnuradio-5d7b2c44396ef6991b049d2d15ebf5b822690961.tar.gz
gnuradio-5d7b2c44396ef6991b049d2d15ebf5b822690961.tar.bz2
gnuradio-5d7b2c44396ef6991b049d2d15ebf5b822690961.zip
Merge branch 'master' of http://gnuradio.org/git/gnuradio into uhd
-rw-r--r--gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc1
-rw-r--r--gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc1
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am3
-rw-r--r--gnuradio-core/src/lib/general/general.i2
-rw-r--r--gnuradio-core/src/lib/general/gr_additive_scrambler_bb.cc65
-rw-r--r--gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h67
-rw-r--r--gnuradio-core/src/lib/general/gr_additive_scrambler_bb.i31
-rw-r--r--gnuradio-core/src/lib/general/gri_lfsr.h12
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_scrambler.py20
-rw-r--r--gr-gpio/src/python/gpio.py2
-rw-r--r--grc/blocks/Makefile.am1
-rw-r--r--grc/blocks/block_tree.xml1
-rw-r--r--grc/blocks/gr_additive_scrambler_bb.xml44
-rw-r--r--grc/blocks/usrp_dual_source_x.xml36
-rw-r--r--grc/grc_gnuradio/usrp/dual_usrp.py8
-rw-r--r--grc/gui/DrawingArea.py12
-rw-r--r--grc/gui/FlowGraph.py41
17 files changed, 326 insertions, 21 deletions
diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc
index 1e7fbe214..1bf4a6f4b 100644
--- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc
+++ b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc
@@ -29,6 +29,7 @@
#include <assert.h>
#include <stdexcept>
#include <cstdio>
+#include <cstring>
#include <fftw3.h>
gri_fft_filter_ccc_generic::gri_fft_filter_ccc_generic (int decimation,
diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc
index 5a0916669..74058fa93 100644
--- a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc
+++ b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc
@@ -29,6 +29,7 @@
#include <assert.h>
#include <stdexcept>
#include <cstdio>
+#include <cstring>
gri_fft_filter_fff_generic::gri_fft_filter_fff_generic (int decimation,
const std::vector<float> &taps)
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am
index ecef7d6e3..b5f5c346b 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -34,6 +34,7 @@ EXTRA_DIST = \
gr_constants.cc.in
libgeneral_la_SOURCES = \
+ gr_additive_scrambler_bb.cc \
gr_agc_cc.cc \
gr_agc_ff.cc \
gr_agc2_cc.cc \
@@ -188,6 +189,7 @@ libgeneral_qa_la_SOURCES = \
qa_gri_lfsr.cc
grinclude_HEADERS = \
+ gr_additive_scrambler_bb.h \
gr_agc_cc.h \
gr_agc_ff.h \
gr_agc2_cc.h \
@@ -360,6 +362,7 @@ noinst_HEADERS = \
if PYTHON
swiginclude_HEADERS = \
general.i \
+ gr_additive_scrambler_bb.i \
gr_agc_cc.i \
gr_agc_ff.i \
gr_agc2_cc.i \
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index 2c26b59cd..6929f1e6e 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -141,6 +141,7 @@
#include <gr_wvps_ff.h>
#include <gr_copy.h>
#include <gr_fll_band_edge_cc.h>
+#include <gr_additive_scrambler_bb.h>
%}
%include "gr_nop.i"
@@ -262,3 +263,4 @@
%include "gr_wvps_ff.i"
%include "gr_copy.i"
%include "gr_fll_band_edge_cc.i"
+%include "gr_additive_scrambler_bb.i"
diff --git a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.cc b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.cc
new file mode 100644
index 000000000..91e02c2d3
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.cc
@@ -0,0 +1,65 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2010 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_additive_scrambler_bb.h>
+#include <gr_io_signature.h>
+
+gr_additive_scrambler_bb_sptr
+gr_make_additive_scrambler_bb(int mask, int seed, int len, int count)
+{
+ return gr_additive_scrambler_bb_sptr(new gr_additive_scrambler_bb(mask, seed, len, count));
+}
+
+gr_additive_scrambler_bb::gr_additive_scrambler_bb(int mask, int seed, int len, int count)
+ : gr_sync_block("additive_scrambler_bb",
+ gr_make_io_signature (1, 1, sizeof (unsigned char)),
+ gr_make_io_signature (1, 1, sizeof (unsigned char))),
+ d_lfsr(mask, seed, len),
+ d_count(count),
+ d_bits(0)
+{
+}
+
+int
+gr_additive_scrambler_bb::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const unsigned char *in = (const unsigned char *) input_items[0];
+ unsigned char *out = (unsigned char *) output_items[0];
+
+ for (int i = 0; i < noutput_items; i++) {
+ out[i] = in[i]^d_lfsr.next_bit();
+ if (d_count > 0) {
+ if (++d_bits == d_count) {
+ d_lfsr.reset();
+ d_bits = 0;
+ }
+ }
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h
new file mode 100644
index 000000000..6c9493050
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h
@@ -0,0 +1,67 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2010 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H
+#define INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H
+
+#include <gr_sync_block.h>
+#include "gri_lfsr.h"
+
+class gr_additive_scrambler_bb;
+typedef boost::shared_ptr<gr_additive_scrambler_bb> gr_additive_scrambler_bb_sptr;
+
+gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask, int seed, int len, int count=0);
+
+/*!
+ * Scramble an input stream using an LFSR. This block works on the LSB only
+ * of the input data stream, i.e., on an "unpacked binary" stream, and
+ * produces the same format on its output.
+ *
+ * \param mask Polynomial mask for LFSR
+ * \param seed Initial shift register contents
+ * \param len Shift register length
+ * \param count Number of bits after which shift register is reset, 0=never
+ *
+ * The scrambler works by XORing the incoming bit stream by the output of
+ * the LFSR. Optionally, after 'count' bits have been processed, the shift
+ * register is reset to the seed value. This allows processing fixed length
+ * vectors of samples.
+ *
+ * \ingroup coding_blk
+ */
+
+class gr_additive_scrambler_bb : public gr_sync_block
+{
+ friend gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask, int seed, int len, int count);
+
+ gri_lfsr d_lfsr;
+ int d_count;
+ int d_bits;
+
+ gr_additive_scrambler_bb(int mask, int seed, int len, int count);
+
+public:
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H */
diff --git a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.i b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.i
new file mode 100644
index 000000000..0ca9c1cd7
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.i
@@ -0,0 +1,31 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2010 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,additive_scrambler_bb);
+
+gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask, int seed, int len, int count=0);
+
+class gr_additive_scrambler_bb : public gr_sync_block
+{
+private:
+ gr_additive_scrambler_bb(int mask, int seed, int len, int count);
+};
diff --git a/gnuradio-core/src/lib/general/gri_lfsr.h b/gnuradio-core/src/lib/general/gri_lfsr.h
index 715da78a9..f691e36ec 100644
--- a/gnuradio-core/src/lib/general/gri_lfsr.h
+++ b/gnuradio-core/src/lib/general/gri_lfsr.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008 Free Software Foundation, Inc.
+ * Copyright 2008,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -86,6 +86,7 @@ class gri_lfsr
private:
uint32_t d_shift_register;
uint32_t d_mask;
+ uint32_t d_seed;
uint32_t d_shift_register_length; // less than 32
static uint32_t
@@ -99,7 +100,10 @@ class gri_lfsr
public:
gri_lfsr(uint32_t mask, uint32_t seed, uint32_t reg_len)
- : d_shift_register(seed), d_mask(mask), d_shift_register_length(reg_len)
+ : d_shift_register(seed),
+ d_mask(mask),
+ d_seed(seed),
+ d_shift_register_length(reg_len)
{
if (reg_len > 31)
throw std::invalid_argument("reg_len must be <= 31");
@@ -126,6 +130,10 @@ class gri_lfsr
return output;
}
+ /*!
+ * Reset shift register to initial seed value
+ */
+ void reset() { d_shift_register = d_seed; }
/*!
* Rotate the register through x number of bits
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py b/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py
index 76b0e62fa..aecf49293 100755
--- a/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py
@@ -40,5 +40,25 @@ class test_scrambler(gr_unittest.TestCase):
self.tb.run()
self.assertEqual(tuple(src_data[:-8]), dst.data()[8:]) # skip garbage during synchronization
+ def test_additive_scrambler(self):
+ src_data = (1,)*1000
+ src = gr.vector_source_b(src_data, False)
+ scrambler = gr.additive_scrambler_bb(0x8a, 0x7f, 7)
+ descrambler = gr.additive_scrambler_bb(0x8a, 0x7f, 7)
+ dst = gr.vector_sink_b()
+ self.tb.connect(src, scrambler, descrambler, dst)
+ self.tb.run()
+ self.assertEqual(src_data, dst.data())
+
+ def test_additive_scrambler_reset(self):
+ src_data = (1,)*1000
+ src = gr.vector_source_b(src_data, False)
+ scrambler = gr.additive_scrambler_bb(0x8a, 0x7f, 7, 100)
+ descrambler = gr.additive_scrambler_bb(0x8a, 0x7f, 7, 100)
+ dst = gr.vector_sink_b()
+ self.tb.connect(src, scrambler, descrambler, dst)
+ self.tb.run()
+ self.assertEqual(src_data, dst.data())
+
if __name__ == '__main__':
gr_unittest.main ()
diff --git a/gr-gpio/src/python/gpio.py b/gr-gpio/src/python/gpio.py
index 2ef495589..a315e166b 100644
--- a/gr-gpio/src/python/gpio.py
+++ b/gr-gpio/src/python/gpio.py
@@ -1,3 +1 @@
-from gpio_swig import *
-
fpga_filename = 'std_2rxint_2tx_dig.rbf'
diff --git a/grc/blocks/Makefile.am b/grc/blocks/Makefile.am
index a284d6d85..4e3839d27 100644
--- a/grc/blocks/Makefile.am
+++ b/grc/blocks/Makefile.am
@@ -67,6 +67,7 @@ dist_ourdata_DATA = \
const_source_x.xml \
gr_add_const_vxx.xml \
gr_add_xx.xml \
+ gr_additive_scrambler_bb.xml \
gr_agc2_xx.xml \
gr_agc_xx.xml \
gr_and_xx.xml \
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index ba597756f..04568e19a 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -259,6 +259,7 @@
<name>Line Coding</name>
<block>gr_scrambler_bb</block>
<block>gr_descrambler_bb</block>
+ <block>gr_additive_scrambler_bb</block>
</cat>
<cat>
<name>Vocoders</name>
diff --git a/grc/blocks/gr_additive_scrambler_bb.xml b/grc/blocks/gr_additive_scrambler_bb.xml
new file mode 100644
index 000000000..a15d6eefb
--- /dev/null
+++ b/grc/blocks/gr_additive_scrambler_bb.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## Additive Scrambler
+###################################################
+ -->
+<block>
+ <name>Additive Scrambler</name>
+ <key>gr_additive_scrambler_bb</key>
+ <import>from gnuradio import gr</import>
+ <make>gr.additive_scrambler_bb($mask, $seed, $len, $count)</make>
+ <param>
+ <name>Mask</name>
+ <key>mask</key>
+ <value>0x8A</value>
+ <type>hex</type>
+ </param>
+ <param>
+ <name>Seed</name>
+ <key>seed</key>
+ <value>0x7F</value>
+ <type>hex</type>
+ </param>
+ <param>
+ <name>Length</name>
+ <key>len</key>
+ <value>7</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Count</name>
+ <key>count</key>
+ <value>0</value>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>byte</type>
+ </source>
+</block>
diff --git a/grc/blocks/usrp_dual_source_x.xml b/grc/blocks/usrp_dual_source_x.xml
index ad9a860ac..07d3174bb 100644
--- a/grc/blocks/usrp_dual_source_x.xml
+++ b/grc/blocks/usrp_dual_source_x.xml
@@ -8,7 +8,11 @@
<name>USRP Dual Source</name>
<key>usrp_dual_source_x</key>
<import>from grc_gnuradio import usrp as grc_usrp</import>
- <make>grc_usrp.dual_source_$(type.fcn)(which=$which, rx_ant_a=$rx_ant_a, rx_ant_b=$rx_ant_b)
+ <make>grc_usrp.dual_source_$(type.fcn)(
+ which=$which,
+ rx_ant_a=$rx_ant_a, rx_ant_b=$rx_ant_b,
+ rx_source_a=$rx_source_a, rx_source_b=$rx_source_b,
+)
#if $format()
self.$(id).set_format(width=$format.width, shift=$format.shift)
#end if
@@ -189,6 +193,36 @@ self.$(id).set_gain_b($gain_b)</make>
<key>RX2</key>
</option>
</param>
+ <param>
+ <name>RX Source A</name>
+ <key>rx_source_a</key>
+ <value>A</value>
+ <type>string</type>
+ <hide>#if $rx_source_a() == 'A' then 'part' else 'none'#</hide>
+ <option>
+ <name>Side A</name>
+ <key>A</key>
+ </option>
+ <option>
+ <name>Side B</name>
+ <key>B</key>
+ </option>
+ </param>
+ <param>
+ <name>RX Source B</name>
+ <key>rx_source_b</key>
+ <value>B</value>
+ <type>string</type>
+ <hide>#if $rx_source_b() == 'B' then 'part' else 'none'#</hide>
+ <option>
+ <name>Side A</name>
+ <key>A</key>
+ </option>
+ <option>
+ <name>Side B</name>
+ <key>B</key>
+ </option>
+ </param>
<source>
<name>Aout</name>
<type>$type</type>
diff --git a/grc/grc_gnuradio/usrp/dual_usrp.py b/grc/grc_gnuradio/usrp/dual_usrp.py
index b26dbddd4..66b76b2df 100644
--- a/grc/grc_gnuradio/usrp/dual_usrp.py
+++ b/grc/grc_gnuradio/usrp/dual_usrp.py
@@ -1,4 +1,4 @@
-# Copyright 2009 Free Software Foundation, Inc.
+# Copyright 2009, 2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -27,7 +27,7 @@ from gnuradio import gr
class _dual_source(gr.hier_block2):
"""A dual usrp source of IO type short or complex."""
- def __init__(self, which, rx_ant_a='RXA', rx_ant_b='RXA'):
+ def __init__(self, which, rx_ant_a='RXA', rx_ant_b='RXA', rx_source_a='A', rx_source_b='B'):
"""
USRP dual source contructor.
@param which the unit number
@@ -42,8 +42,8 @@ class _dual_source(gr.hier_block2):
)
#create usrp object
self._make_usrp(which=which, nchan=2)
- subdev_spec_a = common.to_spec('A', rx_ant_a)
- subdev_spec_b = common.to_spec('B', rx_ant_b)
+ subdev_spec_a = common.to_spec(rx_source_a, rx_ant_a)
+ subdev_spec_b = common.to_spec(rx_source_b, rx_ant_b)
self._get_u().set_mux(self._get_u().determine_rx_mux_value(subdev_spec_a, subdev_spec_b))
self._subdev_a = self._get_u().selected_subdev(subdev_spec_a)
self._subdev_b = self._get_u().selected_subdev(subdev_spec_b)
diff --git a/grc/gui/DrawingArea.py b/grc/gui/DrawingArea.py
index b70468ed0..790df7c3f 100644
--- a/grc/gui/DrawingArea.py
+++ b/grc/gui/DrawingArea.py
@@ -1,5 +1,5 @@
"""
-Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
+Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
@@ -82,19 +82,21 @@ class DrawingArea(gtk.DrawingArea):
Forward button click information to the flow graph.
"""
self.ctrl_mask = event.state & gtk.gdk.CONTROL_MASK
- self._flow_graph.handle_mouse_button_press(
- left_click=(event.button == 1),
+ if event.button == 1: self._flow_graph.handle_mouse_selector_press(
double_click=(event.type == gtk.gdk._2BUTTON_PRESS),
coordinate=(event.x, event.y),
)
+ if event.button == 3: self._flow_graph.handle_mouse_context_press(
+ coordinate=(event.x, event.y),
+ event=event,
+ )
def _handle_mouse_button_release(self, widget, event):
"""
Forward button release information to the flow graph.
"""
self.ctrl_mask = event.state & gtk.gdk.CONTROL_MASK
- self._flow_graph.handle_mouse_button_release(
- left_click=(event.button == 1),
+ if event.button == 1: self._flow_graph.handle_mouse_selector_release(
coordinate=(event.x, event.y),
)
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 5adecccc1..897145a1d 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -1,5 +1,5 @@
"""
-Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
+Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
@@ -51,6 +51,19 @@ class FlowGraph(Element):
#selected ports
self._old_selected_port = None
self._new_selected_port = None
+ #context menu
+ self._context_menu = gtk.Menu()
+ for action in [
+ Actions.BLOCK_CUT,
+ Actions.BLOCK_COPY,
+ Actions.BLOCK_PASTE,
+ Actions.ELEMENT_DELETE,
+ Actions.BLOCK_ROTATE_CCW,
+ Actions.BLOCK_ROTATE_CW,
+ Actions.BLOCK_ENABLE,
+ Actions.BLOCK_DISABLE,
+ Actions.BLOCK_PARAM_MODIFY,
+ ]: self._context_menu.append(action.create_menu_item())
###########################################################################
# Access Drawing Area
@@ -425,14 +438,27 @@ class FlowGraph(Element):
##########################################################################
## Event Handlers
##########################################################################
- def handle_mouse_button_press(self, left_click, double_click, coordinate):
+ def handle_mouse_context_press(self, coordinate, event):
"""
- A mouse button is pressed, only respond to left clicks.
+ The context mouse button was pressed:
+ If no elements were selected, perform re-selection at this coordinate.
+ Then, show the context menu at the mouse click location.
+ """
+ selections = self.what_is_selected(coordinate)
+ if not set(selections).intersection(self.get_selected_elements()):
+ self.set_coordinate(coordinate)
+ self.mouse_pressed = True
+ self.update_selected_elements()
+ self.mouse_pressed = False
+ self._context_menu.popup(None, None, None, event.button, event.time)
+
+ def handle_mouse_selector_press(self, double_click, coordinate):
+ """
+ The selector mouse button was pressed:
Find the selected element. Attempt a new connection if possible.
Open the block params window on a double click.
Update the selection state of the flow graph.
"""
- if not left_click: return
self.press_coor = coordinate
self.set_coordinate(coordinate)
self.time = 0
@@ -444,11 +470,12 @@ class FlowGraph(Element):
self.mouse_pressed = False
Actions.BLOCK_PARAM_MODIFY()
- def handle_mouse_button_release(self, left_click, coordinate):
+ def handle_mouse_selector_release(self, coordinate):
"""
- A mouse button is released, record the state.
+ The selector mouse button was released:
+ Update the state, handle motion (dragging).
+ And update the selected flowgraph elements.
"""
- if not left_click: return
self.set_coordinate(coordinate)
self.time = 0
self.mouse_pressed = False