]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/view.cpp
Trace View: Move ruler time conversion from View to Ruler
[pulseview.git] / pv / views / trace / view.cpp
index 2a4c4372194749d5c9ce9a6d0bf377d507f1cfd6..4b95a806a490cf492ad33cb6e2b537b5f8744165 100644 (file)
@@ -493,6 +493,11 @@ void View::reset_zero_position()
        ruler_->update();
 }
 
+pv::util::Timestamp View::zero_offset() const
+{
+       return zero_offset_;
+}
+
 int View::owner_visual_v_offset() const
 {
        return -scrollarea_->verticalScrollBar()->sliderPosition();
@@ -790,37 +795,36 @@ bool View::cursors_shown() const
 
 void View::show_cursors(bool show)
 {
-    if (show_cursors_ != show) {
-        show_cursors_ = show;
-        cursor_state_changed(show);
-        ruler_->update();
-        viewport_->update();
+       if (show_cursors_ != show) {
+               show_cursors_ = show;
 
-    } else {
-        show_cursors_ = show;
-    }
+               cursor_state_changed(show);
+               ruler_->update();
+               viewport_->update();
+       }
 }
 
-void View::set_cursors(pv::util::Timestamp& first, pv::util::Timestamp& second) {
-    assert(cursors);
+void View::set_cursors(pv::util::Timestamp& first, pv::util::Timestamp& second)
+{
+       assert(cursors_);
 
-    cursors_->first()->set_time(first);
-    cursors_->second()->set_time(second);
+       cursors_->first()->set_time(first);
+       cursors_->second()->set_time(second);
 
-    ruler_->update();
-    viewport_->update();
+       ruler_->update();
+       viewport_->update();
 }
 
 void View::centre_cursors()
 {
-    assert(cursors);
+       assert(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);
+       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);
 
-    ruler_->update();
-    viewport_->update();
+       ruler_->update();
+       viewport_->update();
 }
 
 shared_ptr<CursorPair> View::cursors() const