summaryrefslogtreecommitdiff
path: root/gr-qtgui/lib/freq_sink_f_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-qtgui/lib/freq_sink_f_impl.cc')
-rw-r--r--gr-qtgui/lib/freq_sink_f_impl.cc49
1 files changed, 48 insertions, 1 deletions
diff --git a/gr-qtgui/lib/freq_sink_f_impl.cc b/gr-qtgui/lib/freq_sink_f_impl.cc
index b661f7b07b..ab6167d10a 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.cc
+++ b/gr-qtgui/lib/freq_sink_f_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012,2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -69,6 +69,13 @@ namespace gr {
d_argv = new char;
d_argv[0] = '\0';
+ // setup output message port to post frequency when display is
+ // double-clicked
+ message_port_register_out(pmt::mp("freq"));
+ message_port_register_in(pmt::mp("freq"));
+ set_msg_handler(pmt::mp("freq"),
+ boost::bind(&freq_sink_f_impl::handle_set_freq, this, _1));
+
d_main_gui = NULL;
// Perform fftshift operation;
@@ -150,6 +157,9 @@ namespace gr {
set_fft_size(d_fftsize);
set_frequency_range(d_center_freq, d_bandwidth);
+ if(d_name.size() > 0)
+ set_title(d_name);
+
// initialize update time to 10 times a second
set_update_time(0.1);
}
@@ -352,6 +362,18 @@ namespace gr {
}
void
+ freq_sink_f_impl::clear_max_hold()
+ {
+ d_main_gui->clearMaxHold();
+ }
+
+ void
+ freq_sink_f_impl::clear_min_hold()
+ {
+ d_main_gui->clearMinHold();
+ }
+
+ void
freq_sink_f_impl::reset()
{
d_index = 0;
@@ -447,6 +469,30 @@ namespace gr {
}
}
+ void
+ freq_sink_f_impl::check_clicked()
+ {
+ if(d_main_gui->checkClicked()) {
+ double freq = d_main_gui->getClickedFreq();
+ message_port_pub(pmt::mp("freq"),
+ pmt::cons(pmt::mp("freq"),
+ pmt::from_double(freq)));
+ }
+ }
+
+ void
+ freq_sink_f_impl::handle_set_freq(pmt::pmt_t msg)
+ {
+ if(pmt::is_pair(msg)) {
+ pmt::pmt_t x = pmt::cdr(msg);
+ if(pmt::is_real(x)) {
+ d_center_freq = pmt::to_double(x);
+ d_qApplication->postEvent(d_main_gui,
+ new SetFreqEvent(d_center_freq, d_bandwidth));
+ }
+ }
+ }
+
int
freq_sink_f_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -458,6 +504,7 @@ namespace gr {
// Update the FFT size from the application
fftresize();
windowreset();
+ check_clicked();
for(int i=0; i < noutput_items; i+=d_fftsize) {
unsigned int datasize = noutput_items - i;