X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fviews%2Fviewbase.cpp;h=c463ecc2d1a8dc16792a2c25a58f45836b8caaf7;hb=c78081004d8d7c6440358ccbf9278826a0fdb568;hp=382e1154727cfc3d8a4e0dfbc24ac7fb46d741fc;hpb=f4e57597347e47a4ea58fbdc7b0a22e07f1c0ede;p=pulseview.git
diff --git a/pv/views/viewbase.cpp b/pv/views/viewbase.cpp
index 382e115..c463ecc 100644
--- a/pv/views/viewbase.cpp
+++ b/pv/views/viewbase.cpp
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see .
*/
#ifdef ENABLE_DECODE
@@ -27,14 +26,19 @@
#include "pv/session.hpp"
#include "pv/util.hpp"
+#include "pv/data/segment.hpp"
using std::shared_ptr;
namespace pv {
namespace views {
-ViewBase::ViewBase(Session &session, QWidget *parent) :
- session_(session)
+const int ViewBase::MaxViewAutoUpdateRate = 25; // No more than 25 Hz
+
+ViewBase::ViewBase(Session &session, bool is_main_view, QWidget *parent) :
+ // Note: Place defaults in ViewBase::reset_view_state(), not here
+ session_(session),
+ is_main_view_(is_main_view)
{
(void)parent;
@@ -42,10 +46,19 @@ ViewBase::ViewBase(Session &session, QWidget *parent) :
this, SLOT(signals_changed()));
connect(&session_, SIGNAL(capture_state_changed(int)),
this, SLOT(capture_state_updated(int)));
- connect(&session_, SIGNAL(data_received()),
- this, SLOT(data_updated()));
- connect(&session_, SIGNAL(frame_ended()),
- this, SLOT(data_updated()));
+ connect(&session_, SIGNAL(new_segment(int)),
+ this, SLOT(on_new_segment(int)));
+
+ connect(&delayed_view_updater_, SIGNAL(timeout()),
+ this, SLOT(perform_delayed_view_update()));
+ delayed_view_updater_.setSingleShot(true);
+ delayed_view_updater_.setInterval(1000 / MaxViewAutoUpdateRate);
+}
+
+void ViewBase::reset_view_state()
+{
+ ruler_shift_ = 0;
+ current_segment_ = 0;
}
Session& ViewBase::session()
@@ -62,19 +75,46 @@ void ViewBase::clear_signals()
{
}
+unordered_set< shared_ptr > ViewBase::signalbases() const
+{
+ return signalbases_;
+}
+
+void ViewBase::clear_signalbases()
+{
+ for (shared_ptr signalbase : signalbases_) {
+ disconnect(signalbase.get(), SIGNAL(samples_cleared()),
+ this, SLOT(on_data_updated()));
+ disconnect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)),
+ this, SLOT(on_samples_added(uint64_t, uint64_t, uint64_t)));
+ }
+
+ signalbases_.clear();
+}
+
+void ViewBase::add_signalbase(const shared_ptr signalbase)
+{
+ signalbases_.insert(signalbase);
+
+ connect(signalbase.get(), SIGNAL(samples_cleared()),
+ this, SLOT(on_data_updated()));
+ connect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)),
+ this, SLOT(on_samples_added(uint64_t, uint64_t, uint64_t)));
+}
+
#ifdef ENABLE_DECODE
void ViewBase::clear_decode_signals()
{
}
-void ViewBase::add_decode_signal(shared_ptr signalbase)
+void ViewBase::add_decode_signal(shared_ptr signal)
{
- (void)signalbase;
+ (void)signal;
}
-void ViewBase::remove_decode_signal(shared_ptr signalbase)
+void ViewBase::remove_decode_signal(shared_ptr signal)
{
- (void)signalbase;
+ (void)signal;
}
#endif
@@ -88,8 +128,9 @@ void ViewBase::restore_settings(QSettings &settings)
(void)settings;
}
-void ViewBase::trigger_event(util::Timestamp location)
+void ViewBase::trigger_event(int segment_id, util::Timestamp location)
{
+ (void)segment_id;
(void)location;
}
@@ -97,14 +138,43 @@ void ViewBase::signals_changed()
{
}
+void ViewBase::on_new_segment(int new_segment_id)
+{
+ (void)new_segment_id;
+}
+
+void ViewBase::on_segment_completed(int new_segment_id)
+{
+ (void)new_segment_id;
+}
+
void ViewBase::capture_state_updated(int state)
{
(void)state;
}
-void ViewBase::data_updated()
+void ViewBase::perform_delayed_view_update()
+{
+}
+
+void ViewBase::on_samples_added(uint64_t segment_id, uint64_t start_sample,
+ uint64_t end_sample)
+{
+ (void)start_sample;
+ (void)end_sample;
+
+ if (segment_id != current_segment_)
+ return;
+
+ if (!delayed_view_updater_.isActive())
+ delayed_view_updater_.start();
+}
+
+void ViewBase::on_data_updated()
{
+ if (!delayed_view_updater_.isActive())
+ delayed_view_updater_.start();
}
-} // namespace view
+} // namespace views
} // namespace pv