Markers are movable indicators that you can create wherever you like on the
time scale - just double-click on it and it'll create one for you where your
-mouse cursor is at the time, or use the context menu when right-clicking.
+mouse cursor is at the time, or use the context menu when right-clicking on
+the ruler or a signal trace.
You can click on its label and you'll have the option to change its name, or
drag it to reposition it.
QMenu* DecodeTrace::create_view_context_menu(QWidget *parent, QPoint &click_pos)
{
+ // Get entries from default menu before adding our own
+ QMenu *const menu = new QMenu(parent);
+
+ QMenu* default_menu = Trace::create_view_context_menu(parent, click_pos);
+ if (default_menu) {
+ for (QAction *action : default_menu->actions()) {
+ menu->addAction(action);
+ if (action->parent() == default_menu)
+ action->setParent(menu);
+ }
+ delete default_menu;
+
+ // Add separator if needed
+ if (menu->actions().length() > 0)
+ menu->addSeparator();
+ }
+
try {
selected_row_ = &visible_rows_[get_row_at_point(click_pos)];
} catch (out_of_range&) {
get_view_sample_range(click_pos.x(), click_pos.x() + 1);
selected_sample_range_ = make_pair(sample_range.first, numeric_limits<uint64_t>::max());
- QMenu *const menu = new QMenu(parent);
-
if (decode_signal_->is_paused()) {
QAction *const resume =
new QAction(tr("Resume decoding"), this);
return pv::util::format_time_minutes(t, precision, sign);
}
-pv::util::Timestamp Ruler::get_time_from_x_pos(uint32_t x)
+pv::util::Timestamp Ruler::get_time_from_x_pos(uint32_t x) const
{
return view_.ruler_offset() + ((double)x + 0.5) * view_.scale();
}
void Ruler::on_createMarker()
{
- view_.add_flag(get_time_from_x_pos(context_menu_x_pos_));
+ view_.add_flag(get_time_from_x_pos(mouse_down_point_.x()));
}
void Ruler::on_toggleHoverMarker()
unsigned precision = 0,
bool sign = true);
- pv::util::Timestamp get_time_from_x_pos(uint32_t x);
+ pv::util::Timestamp get_time_from_x_pos(uint32_t x) const;
protected:
virtual void contextMenuEvent(QContextMenuEvent *event) override;
#include <QFormLayout>
#include <QKeyEvent>
#include <QLineEdit>
+#include <QMenu>
+#include "ruler.hpp"
#include "trace.hpp"
#include "tracepalette.hpp"
#include "view.hpp"
return menu;
}
+QMenu* Trace::create_view_context_menu(QWidget *parent, QPoint &click_pos)
+{
+ context_menu_x_pos_ = click_pos.x();
+
+ // Get entries from default menu before adding our own
+ QMenu *const menu = new QMenu(parent);
+
+ QMenu* default_menu = TraceTreeItem::create_view_context_menu(parent, click_pos);
+ if (default_menu) {
+ for (QAction *action : default_menu->actions()) {
+ menu->addAction(action);
+ if (action->parent() == default_menu)
+ action->setParent(menu);
+ }
+ delete default_menu;
+
+ // Add separator if needed
+ if (menu->actions().length() > 0)
+ menu->addSeparator();
+ }
+
+ QAction *const create_marker_here = new QAction(tr("Create marker here"), this);
+ connect(create_marker_here, SIGNAL(triggered()), this, SLOT(on_create_marker_here()));
+ menu->addAction(create_marker_here);
+
+ return menu;
+}
+
pv::widgets::Popup* Trace::create_popup(QWidget *parent)
{
using pv::widgets::Popup;
base_->set_color(color);
}
+void Trace::on_create_marker_here() const
+{
+ View *view = owner_->view();
+ assert(view);
+
+ const Ruler *ruler = view->ruler();
+ QPoint p = ruler->mapFrom(view, QPoint(context_menu_x_pos_, 0));
+
+ view->add_flag(ruler->get_time_from_x_pos(p.x()));
+}
+
} // namespace trace
} // namespace views
} // namespace pv
virtual QMenu* create_header_context_menu(QWidget *parent);
+ virtual QMenu* create_view_context_menu(QWidget *parent, QPoint &click_pos);
+
pv::widgets::Popup* create_popup(QWidget *parent);
/**
void on_coloredit_changed(const QColor &color);
+ void on_create_marker_here() const;
+
protected:
shared_ptr<data::SignalBase> base_;
QPen axis_pen_;
SegmentDisplayMode segment_display_mode_;
bool show_hover_marker_;
+ uint32_t context_menu_x_pos_;
+
/// The ID of the currently displayed segment
int current_segment_;
return viewport_;
}
+const Ruler* View::ruler() const
+{
+ return ruler_;
+}
+
void View::save_settings(QSettings &settings) const
{
settings.setValue("scale", scale_);
const Viewport* viewport() const;
+ const Ruler* ruler() const;
+
virtual void save_settings(QSettings &settings) const;
virtual void restore_settings(QSettings &settings);