X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fruler.hpp;h=55c156f5942e34f8a97912322b25a3b2df4c669b;hb=e6d85b8936b5b7aee80b03834f095fd5b52fe6f4;hp=0c614c6c8bad27360b4cca6ada99dbe91320d709;hpb=ffc00fdd5946593ad2a587078fd4ee9ba0a507ec;p=pulseview.git
diff --git a/pv/views/trace/ruler.hpp b/pv/views/trace/ruler.hpp
index 0c614c6c..55c156f5 100644
--- a/pv/views/trace/ruler.hpp
+++ b/pv/views/trace/ruler.hpp
@@ -17,8 +17,8 @@
* along with this program; if not, see .
*/
-#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_RULER_HPP
-#define PULSEVIEW_PV_VIEWS_TRACEVIEW_RULER_HPP
+#ifndef PULSEVIEW_PV_VIEWS_TRACE_RULER_HPP
+#define PULSEVIEW_PV_VIEWS_TRACE_RULER_HPP
#include
#include
@@ -46,6 +46,12 @@ namespace trace {
class TimeItem;
class ViewItem;
+struct TickPositions
+{
+ vector> major;
+ vector minor;
+};
+
/**
* The Ruler class manages and displays the time scale above the trace canvas.
* It may also contain @ref TimeItem instances used to identify or highlight
@@ -63,15 +69,12 @@ private:
/// Height of the ruler in multipes of the text height
static const float RulerHeight;
- static const int MinorTickSubdivision;
-
/// Height of the hover arrow in multiples of the text height
static const float HoverArrowSize;
public:
Ruler(View &parent);
-public:
QSize sizeHint() const override;
/**
@@ -114,6 +117,19 @@ public:
unsigned precision = 0,
bool sign = true);
+ pv::util::Timestamp get_absolute_time_from_x_pos(uint32_t x) const;
+ pv::util::Timestamp get_ruler_time_from_x_pos(uint32_t x) const;
+
+ pv::util::Timestamp get_ruler_time_from_absolute_time(const pv::util::Timestamp& abs_time) const;
+ pv::util::Timestamp get_absolute_time_from_ruler_time(const pv::util::Timestamp& ruler_time) const;
+
+ shared_ptr get_reference_item() const;
+
+protected:
+ virtual void contextMenuEvent(QContextMenuEvent *event) override;
+ void resizeEvent(QResizeEvent*) override;
+ virtual void item_hover(const shared_ptr &item, QPoint pos) override;
+
private:
/**
* Gets the time items.
@@ -128,10 +144,10 @@ private:
*/
shared_ptr get_mouse_over_item(const QPoint &pt) override;
- void paintEvent(QPaintEvent *event) override;
-
void mouseDoubleClickEvent(QMouseEvent *event) override;
+ void paintEvent(QPaintEvent *event) override;
+
/**
* Draw a hover arrow under the cursor position.
* @param p The painter to draw into.
@@ -141,18 +157,6 @@ private:
int calculate_text_height() const;
- struct TickPositions
- {
- vector> major;
- vector minor;
- };
-
- /**
- * Holds the tick positions so that they don't have to be recalculated on
- * every redraw. Set by 'paintEvent()' when needed.
- */
- boost::optional tick_position_cache_;
-
/**
* Calculates the major and minor tick positions.
*
@@ -170,20 +174,33 @@ private:
const pv::util::Timestamp& offset,
const double scale,
const int width,
+ const unsigned int minor_tick_count,
function format_function);
-protected:
- void resizeEvent(QResizeEvent*) override;
-
private Q_SLOTS:
- void hover_point_changed(const QPoint &hp);
+ void on_hover_point_changed(const QWidget* widget, const QPoint &hp);
- // Resets the 'tick_position_cache_'.
void invalidate_tick_position_cache();
+
+ void on_createMarker();
+ void on_setZeroPosition();
+ void on_resetZeroPosition();
+ void on_toggleHoverMarker();
+
+private:
+ /**
+ * Holds the tick positions so that they don't have to be recalculated on
+ * every redraw. Set by 'paintEvent()' when needed.
+ */
+ boost::optional tick_position_cache_;
+
+ shared_ptr hover_item_;
+
+ uint32_t context_menu_x_pos_;
};
} // namespace trace
} // namespace views
} // namespace pv
-#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_RULER_HPP
+#endif // PULSEVIEW_PV_VIEWS_TRACE_RULER_HPP