From: Joel Holdsworth Date: Mon, 8 Dec 2014 22:36:54 +0000 (+0000) Subject: TimeItem: Added mandatory set_time virtual method X-Git-Tag: pulseview-0.3.0~378 X-Git-Url: http://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=3b9c4a0df39e718ba69f3c778b51676617aeb1eb TimeItem: Added mandatory set_time virtual method --- diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp index 8a0ecbf2..48109db8 100644 --- a/pv/view/cursorpair.cpp +++ b/pv/view/cursorpair.cpp @@ -59,6 +59,12 @@ shared_ptr CursorPair::second() const return second_; } +void CursorPair::set_time(double time) { + const double delta = second_->time() - first_->time(); + first_->set_time(time); + second_->set_time(time + delta); +} + QPoint CursorPair::point() const { return first_->point(); diff --git a/pv/view/cursorpair.hpp b/pv/view/cursorpair.hpp index 78780916..2c4d5c1c 100644 --- a/pv/view/cursorpair.hpp +++ b/pv/view/cursorpair.hpp @@ -60,6 +60,11 @@ public: */ std::shared_ptr second() const; + /** + * Sets the time of the marker. + */ + void set_time(double time); + QPoint point() const; pv::widgets::Popup* create_popup(QWidget *parent); diff --git a/pv/view/timeitem.hpp b/pv/view/timeitem.hpp index e47f1a6b..eb313a7e 100644 --- a/pv/view/timeitem.hpp +++ b/pv/view/timeitem.hpp @@ -39,6 +39,12 @@ protected: */ TimeItem(View &view); +public: + /** + * Sets the time of the marker. + */ + virtual void set_time(double time) = 0; + protected: View &view_; };