#include "pv/session.hpp"
#include "pv/data/logic.hpp"
-#include "pv/data/logicsnapshot.hpp"
+#include "pv/data/logicsegment.hpp"
#include "pv/util.hpp"
using boost::shared_lock;
using boost::shared_mutex;
using pv::data::SignalData;
+using pv::data::Segment;
using pv::util::format_time;
using std::back_inserter;
tick_period_(0.0),
tick_prefix_(0),
show_cursors_(false),
- cursors_(*this),
+ cursors_(new CursorPair(*this)),
hover_point_(-1, -1)
{
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
connect(&session_, SIGNAL(frame_ended()),
this, SLOT(data_updated()));
- connect(cursors_.first().get(), SIGNAL(time_changed()),
+ connect(cursors_->first().get(), SIGNAL(time_changed()),
this, SLOT(marker_time_changed()));
- connect(cursors_.second().get(), SIGNAL(time_changed()),
+ connect(cursors_->second().get(), SIGNAL(time_changed()),
this, SLOT(marker_time_changed()));
connect(header_, SIGNAL(signals_moved()),
return viewport_;
}
+vector< shared_ptr<TimeItem> > View::time_items() const
+{
+ vector< shared_ptr<TimeItem> > items;
+ items.push_back(cursors_);
+ items.push_back(cursors_->first());
+ items.push_back(cursors_->second());
+ return items;
+}
+
double View::scale() const
{
return scale_;
double samplerate = 0.0;
for (const shared_ptr<SignalData> d : visible_data) {
assert(d);
- samplerate = max(samplerate, d->samplerate());
+ const vector< shared_ptr<Segment> > segments =
+ d->segments();
+ for (const shared_ptr<Segment> &s : segments)
+ samplerate = max(samplerate, s->samplerate());
}
if (samplerate == 0.0)
pair<double, double> View::get_time_extents() const
{
- const set< shared_ptr<SignalData> > visible_data = get_visible_data();
- if (visible_data.empty())
- return make_pair(0.0, 0.0);
-
double left_time = DBL_MAX, right_time = DBL_MIN;
+ const set< shared_ptr<SignalData> > visible_data = get_visible_data();
for (const shared_ptr<SignalData> d : visible_data)
{
- const double start_time = d->get_start_time();
- double samplerate = d->samplerate();
- samplerate = (samplerate <= 0.0) ? 1.0 : samplerate;
-
- left_time = min(left_time, start_time);
- right_time = max(right_time, start_time +
- d->get_max_sample_count() / samplerate);
+ const vector< shared_ptr<Segment> > segments =
+ d->segments();
+ for (const shared_ptr<Segment> &s : segments) {
+ double samplerate = s->samplerate();
+ samplerate = (samplerate <= 0.0) ? 1.0 : samplerate;
+
+ const double start_time = s->start_time();
+ left_time = min(left_time, start_time);
+ right_time = max(right_time, start_time +
+ d->get_max_sample_count() / samplerate);
+ }
}
+ if (left_time == DBL_MAX && right_time == DBL_MIN)
+ return make_pair(0.0, 0.0);
+
assert(left_time < right_time);
return make_pair(left_time, right_time);
}
void View::centre_cursors()
{
const double time_width = scale_ * viewport_->width();
- cursors_.first()->set_time(offset_ + time_width * 0.4);
- cursors_.second()->set_time(offset_ + time_width * 0.6);
+ cursors_->first()->set_time(offset_ + time_width * 0.4);
+ cursors_->second()->set_time(offset_ + time_width * 0.6);
cursorheader_->update();
viewport_->update();
}
-CursorPair& View::cursors()
-{
- return cursors_;
-}
-
-const CursorPair& View::cursors() const
+std::shared_ptr<CursorPair> View::cursors() const
{
return cursors_;
}
get_scroll_layout(length, offset);
length = max(length - areaSize.width(), 0.0);
+ int major_tick_distance = tick_period_ / scale_;
+
horizontalScrollBar()->setPageStep(areaSize.width() / 2);
+ horizontalScrollBar()->setSingleStep(major_tick_distance);
updating_scroll_ = true;
update_scroll();
}
-void View::paint_label(QPainter &p, int right, bool hover)
+void View::paint_label(QPainter &p, const QRect &rect, bool hover)
{
(void)p;
- (void)right;
+ (void)rect;
(void)hover;
}
-QRectF View::label_rect(int right)
+QRectF View::label_rect(const QRectF &rect)
{
- (void)right;
+ (void)rect;
return QRectF();
}