diff --git a/pv/views/trace/ruler.cpp b/pv/views/trace/ruler.cpp index 83ffed28..2305753a 100644 --- a/pv/views/trace/ruler.cpp +++ b/pv/views/trace/ruler.cpp @@ -150,6 +150,12 @@ void Ruler::contextMenuEvent(QContextMenuEvent *event) QMenu *const menu = new QMenu(this); + if(view_.scale() != 1e-3) { + QAction *const reset_zoom = new QAction(tr("Reset zoom"), this); + connect(reset_zoom, SIGNAL(triggered()), this, SLOT(on_zoom_reset())); + menu->addAction(reset_zoom); + } + QAction *const create_marker = new QAction(tr("Create marker here"), this); connect(create_marker, SIGNAL(triggered()), this, SLOT(on_createMarker())); menu->addAction(create_marker); @@ -415,6 +421,11 @@ void Ruler::on_toggleHoverMarker() settings.setValue(GlobalSettings::Key_View_ShowHoverMarker, !state); } +void Ruler::on_zoom_reset() +{ + view_.reset_zoom(); +} + } // namespace trace } // namespace views } // namespace pv diff --git a/pv/views/trace/ruler.hpp b/pv/views/trace/ruler.hpp index 55c156f5..66bd16bc 100644 --- a/pv/views/trace/ruler.hpp +++ b/pv/views/trace/ruler.hpp @@ -186,6 +186,7 @@ private Q_SLOTS: void on_setZeroPosition(); void on_resetZeroPosition(); void on_toggleHoverMarker(); + void on_zoom_reset(); private: /** diff --git a/pv/views/trace/tracetreeitem.cpp b/pv/views/trace/tracetreeitem.cpp index 31b43ca1..e206c170 100644 --- a/pv/views/trace/tracetreeitem.cpp +++ b/pv/views/trace/tracetreeitem.cpp @@ -18,6 +18,7 @@ */ #include +#include #include "view.hpp" @@ -138,6 +139,30 @@ QPoint TraceTreeItem::drag_point(const QRect &rect) const return QPoint(rect.right(), get_visual_y()); } +QMenu* TraceTreeItem::create_view_context_menu(QWidget *parent, QPoint &click_pos) +{ + (void)click_pos; + + QMenu *const menu = new QMenu(parent); + + View *view = owner_->view(); + + if(view->scale() != 1e-3) { + QAction *const reset_zoom = new QAction(tr("Reset zoom"), this); + connect(reset_zoom, SIGNAL(triggered()), this, SLOT(on_zoom_reset())); + menu->addAction(reset_zoom); + } + + return menu; +} + +void TraceTreeItem::on_zoom_reset() +{ + View *view = owner_->view(); + assert(view); + view->reset_zoom(); +} + } // namespace trace } // namespace views } // namespace pv diff --git a/pv/views/trace/tracetreeitem.hpp b/pv/views/trace/tracetreeitem.hpp index e5ebbdd7..d29461aa 100644 --- a/pv/views/trace/tracetreeitem.hpp +++ b/pv/views/trace/tracetreeitem.hpp @@ -119,6 +119,11 @@ class TraceTreeItem : public ViewItem, */ virtual pair v_extents() const = 0; + virtual QMenu* create_view_context_menu(QWidget *parent, QPoint &click_pos); + +private Q_SLOTS: + void on_zoom_reset(); + protected: TraceTreeItemOwner *owner_; diff --git a/pv/views/trace/view.cpp b/pv/views/trace/view.cpp index a7b483a7..4a6603cc 100644 --- a/pv/views/trace/view.cpp +++ b/pv/views/trace/view.cpp @@ -602,6 +602,11 @@ void View::set_offset(const pv::util::Timestamp& offset, bool force_update) } } +void View::reset_zoom() +{ + set_zoom(1e-3, 0); +} + const Timestamp& View::offset() const { return offset_; diff --git a/pv/views/trace/view.hpp b/pv/views/trace/view.hpp index f8506cf4..3dede1c5 100644 --- a/pv/views/trace/view.hpp +++ b/pv/views/trace/view.hpp @@ -184,6 +184,8 @@ class View : public ViewBase, public TraceTreeItemOwner, public GlobalSettingsIn void reset_zero_position(); + void reset_zoom(); + pv::util::Timestamp zero_offset() const; /**