void AnalogSignal::on_samples_added()
{
perform_autoranging(false, false);
-
- if (owner_)
- owner_->row_item_appearance_changed(false, true);
}
void AnalogSignal::on_pos_vdivs_changed(int vdivs)
this, SLOT(on_colour_changed(const QColor&)));
}
+shared_ptr<data::SignalBase> Trace::base() const
+{
+ return base_;
+}
+
void Trace::paint_label(QPainter &p, const QRect &rect, bool hover)
{
const int y = get_visual_y();
namespace pv {
+namespace data {
+class SignalBase;
+}
+
namespace widgets {
class Popup;
}
Trace(shared_ptr<data::SignalBase> channel);
public:
+ /**
+ * Returns the underlying SignalBase instance.
+ */
+ shared_ptr<data::SignalBase> base() const;
+
/**
* Sets the name of the signal.
*/
const Timestamp View::MinScale("1e-12");
const int View::MaxScrollValue = INT_MAX / 2;
-const int View::MaxViewAutoUpdateRate = 25; // No more than 25 Hz with sticky scrolling
const int View::ScaleUnits[3] = {1, 2, 5};
this, SLOT(process_sticky_events()));
lazy_event_handler_.setSingleShot(true);
- connect(&delayed_view_updater_, SIGNAL(timeout()),
- this, SLOT(perform_delayed_view_update()));
- delayed_view_updater_.setSingleShot(true);
- delayed_view_updater_.setInterval(1000 / MaxViewAutoUpdateRate);
-
/* To let the scroll area fill up the parent QWidget (this), we need a layout */
QHBoxLayout *layout = new QHBoxLayout(this);
setLayout(layout);
void View::clear_signals()
{
+ ViewBase::clear_signalbases();
signals_.clear();
}
void View::add_signal(const shared_ptr<Signal> signal)
{
+ ViewBase::add_signalbase(signal->base());
signals_.insert(signal);
}
sticky_events_ |=
(horz ? TraceTreeItemHExtentsChanged : 0) |
(vert ? TraceTreeItemVExtentsChanged : 0);
+
lazy_event_handler_.start();
}
}
}
-void View::data_updated()
-{
- if (always_zoom_to_fit_ || sticky_scrolling_) {
- if (!delayed_view_updater_.isActive())
- delayed_view_updater_.start();
- } else {
- determine_time_unit();
- update_scroll();
- ruler_->update();
- viewport_->update();
- }
-}
-
void View::perform_delayed_view_update()
{
if (always_zoom_to_fit_) {
#include <QAbstractScrollArea>
#include <QSizeF>
-#include <QTimer>
#include <pv/data/signaldata.hpp>
#include <pv/util.hpp>
class Session;
+namespace data {
+class Logic;
+}
+
namespace views {
namespace TraceView {
static const pv::util::Timestamp MinScale;
static const int MaxScrollValue;
- static const int MaxViewAutoUpdateRate;
static const int ScaleUnits[3];
virtual void clear_signals();
- virtual void add_signal(const shared_ptr<Signal> signal);
+ void add_signal(const shared_ptr<Signal> signal);
#ifdef ENABLE_DECODE
virtual void clear_decode_signals();
void signals_changed();
void capture_state_updated(int state);
- void data_updated();
- void perform_delayed_view_update();
+ virtual void perform_delayed_view_update();
void process_sticky_events();
bool sticky_scrolling_;
bool coloured_bg_;
bool always_zoom_to_fit_;
- QTimer delayed_view_updater_;
pv::util::Timestamp tick_period_;
pv::util::SIPrefix tick_prefix_;
namespace pv {
namespace views {
+const int ViewBase::MaxViewAutoUpdateRate = 25; // No more than 25 Hz
+
ViewBase::ViewBase(Session &session, bool is_main_view, QWidget *parent) :
session_(session),
is_main_view_(is_main_view)
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(&delayed_view_updater_, SIGNAL(timeout()),
+ this, SLOT(perform_delayed_view_update()));
+ delayed_view_updater_.setSingleShot(true);
+ delayed_view_updater_.setInterval(1000 / MaxViewAutoUpdateRate);
}
Session& ViewBase::session()
{
}
+unordered_set< shared_ptr<data::SignalBase> > ViewBase::signalbases() const
+{
+ return signalbases_;
+}
+
+void ViewBase::clear_signalbases()
+{
+ for (shared_ptr<data::SignalBase> signalbase : signalbases_) {
+ disconnect(signalbase.get(), SIGNAL(samples_cleared()),
+ this, SLOT(on_data_updated()));
+ disconnect(signalbase.get(), SIGNAL(samples_added(QObject*, uint64_t, uint64_t)),
+ this, SLOT(on_data_updated()));
+ }
+
+ signalbases_.clear();
+}
+
+void ViewBase::add_signalbase(const shared_ptr<data::SignalBase> signalbase)
+{
+ signalbases_.insert(signalbase);
+
+ connect(signalbase.get(), SIGNAL(samples_cleared()),
+ this, SLOT(on_data_updated()));
+ connect(signalbase.get(), SIGNAL(samples_added(QObject*, uint64_t, uint64_t)),
+ this, SLOT(on_data_updated()));
+}
+
#ifdef ENABLE_DECODE
void ViewBase::clear_decode_signals()
{
(void)state;
}
-void ViewBase::data_updated()
+void ViewBase::perform_delayed_view_update()
+{
+}
+
+void ViewBase::on_data_updated()
{
+ if (!delayed_view_updater_.isActive())
+ delayed_view_updater_.start();
}
} // namespace views
#include <cstdint>
#include <memory>
-#include <set>
+#include <unordered_set>
#include <vector>
+#include <QTimer>
#include <QWidget>
#include <pv/data/signalbase.hpp>
#include <pv/util.hpp>
using std::shared_ptr;
+using std::unordered_set;
namespace pv {
{
Q_OBJECT
+private:
+ static const int MaxViewAutoUpdateRate;
+
public:
explicit ViewBase(Session &session, bool is_main_view = false, QWidget *parent = nullptr);
virtual void clear_signals();
+ /**
+ * Returns the signal bases contained in this view.
+ */
+ unordered_set< shared_ptr<data::SignalBase> > signalbases() const;
+
+ virtual void clear_signalbases();
+
+ virtual void add_signalbase(const shared_ptr<data::SignalBase> signalbase);
+
#ifdef ENABLE_DECODE
virtual void clear_decode_signals();
virtual void trigger_event(util::Timestamp location);
virtual void signals_changed();
virtual void capture_state_updated(int state);
- virtual void data_updated();
+ virtual void perform_delayed_view_update();
+
+private Q_SLOTS:
+ void on_data_updated();
protected:
Session &session_;
const bool is_main_view_;
util::TimeUnit time_unit_;
+
+ unordered_set< shared_ptr<data::SignalBase> > signalbases_;
+
+ QTimer delayed_view_updater_;
};
} // namespace views