X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;ds=inline;f=pv%2Fview%2Fcursorpair.cpp;h=e0e3de65f3c9adc427f0ae877e79f0fcb4b0de1e;hb=53bb2e1de75f5cca9244efc83c4e77a222e322f4;hp=aec689193cff79702deec99ff06c76308a32573c;hpb=96b6316ab8ed24551a0affb7a5819d1c97147a5c;p=pulseview.git
diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp
index aec6891..e0e3de6 100644
--- a/pv/view/cursorpair.cpp
+++ b/pv/view/cursorpair.cpp
@@ -14,12 +14,12 @@
* 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 .
*/
#include "cursorpair.hpp"
+#include "ruler.hpp"
#include "view.hpp"
#include "pv/util.hpp"
@@ -33,7 +33,8 @@ using std::shared_ptr;
using std::pair;
namespace pv {
-namespace view {
+namespace views {
+namespace TraceView {
const int CursorPair::DeltaPadding = 8;
const QColor CursorPair::ViewportFillColour(220, 231, 243);
@@ -60,8 +61,9 @@ shared_ptr CursorPair::second() const
return second_;
}
-void CursorPair::set_time(double time) {
- const double delta = second_->time() - first_->time();
+void CursorPair::set_time(const pv::util::Timestamp& time)
+{
+ const pv::util::Timestamp delta = second_->time() - first_->time();
first_->set_time(time);
second_->set_time(time + delta);
}
@@ -118,8 +120,7 @@ void CursorPair::paint_label(QPainter &p, const QRect &rect, bool hover)
const int radius = delta_rect.height() / 2;
const QRectF text_rect(delta_rect.intersected(
rect).adjusted(radius, 0, -radius, 0));
- if (text_rect.width() >= text_size_.width())
- {
+ if (text_rect.width() >= text_size_.width()) {
const int highlight_radius = delta_rect.height() / 2 - 2;
if (selected()) {
@@ -143,7 +144,8 @@ void CursorPair::paint_label(QPainter &p, const QRect &rect, bool hover)
}
}
-void CursorPair::paint_back(QPainter &p, const ViewItemPaintParams &pp) {
+void CursorPair::paint_back(QPainter &p, const ViewItemPaintParams &pp)
+{
if (!enabled())
return;
@@ -161,11 +163,15 @@ void CursorPair::paint_back(QPainter &p, const ViewItemPaintParams &pp) {
QString CursorPair::format_string()
{
- const unsigned int prefix = view_.tick_prefix();
- const double delta = second_->time() - first_->time();
- return QString("%1 / %2").
- arg(util::format_time(delta, prefix, util::TimeUnit::Time, 2)).
- arg(util::format_si_value(1.0 / fabs(delta), "Hz", -1, 4));
+ const pv::util::SIPrefix prefix = view_.tick_prefix();
+ const pv::util::Timestamp diff = abs(second_->time() - first_->time());
+
+ const QString s1 = Ruler::format_time_with_distance(
+ diff, diff, prefix, view_.time_unit(), view_.tick_precision(), false);
+ const QString s2 = util::format_time_si(
+ 1 / diff, pv::util::SIPrefix::unspecified, 4, "Hz", false);
+
+ return QString("%1 / %2").arg(s1).arg(s2);
}
void CursorPair::compute_text_size(QPainter &p)
@@ -182,9 +188,10 @@ pair CursorPair::get_cursor_offsets() const
assert(second_);
return pair(
- (first_->time() - view_.offset()) / view_.scale(),
- (second_->time() - view_.offset()) / view_.scale());
+ ((first_->time() - view_.offset()) / view_.scale()).convert_to(),
+ ((second_->time() - view_.offset()) / view_.scale()).convert_to());
}
-} // namespace view
+} // namespace TraceView
+} // namespace views
} // namespace pv