SLOT(on_view_showAnalogMinorGrid_changed(int)));
trace_view_layout->addRow(tr("Show analog minor grid in addition to div grid"), cb);
+ cb = create_checkbox(GlobalSettings::Key_View_ShowHoverMarker,
+ SLOT(on_view_showHoverMarker_changed(int)));
+ trace_view_layout->addRow(tr("Highlight mouse cursor using a vertical marker line"), cb);
+
QComboBox *thr_disp_mode_cb = new QComboBox();
thr_disp_mode_cb->addItem(tr("None"), GlobalSettings::ConvThrDispMode_None);
thr_disp_mode_cb->addItem(tr("Background"), GlobalSettings::ConvThrDispMode_Background);
settings.setValue(GlobalSettings::Key_View_ShowAnalogMinorGrid, state ? true : false);
}
+void Settings::on_view_showHoverMarker_changed(int state)
+{
+ GlobalSettings settings;
+ settings.setValue(GlobalSettings::Key_View_ShowHoverMarker, state ? true : false);
+}
+
void Settings::on_view_conversionThresholdDispMode_changed(int state)
{
GlobalSettings settings;
void on_view_stickyScrolling_changed(int state);
void on_view_showSamplingPoints_changed(int state);
void on_view_showAnalogMinorGrid_changed(int state);
+ void on_view_showHoverMarker_changed(int state);
void on_view_conversionThresholdDispMode_changed(int state);
void on_view_defaultDivHeight_changed(int value);
void on_view_defaultLogicHeight_changed(int value);
const QString GlobalSettings::Key_View_ConversionThresholdDispMode = "View_ConversionThresholdDispMode";
const QString GlobalSettings::Key_View_DefaultDivHeight = "View_DefaultDivHeight";
const QString GlobalSettings::Key_View_DefaultLogicHeight = "View_DefaultLogicHeight";
+const QString GlobalSettings::Key_View_ShowHoverMarker = "View_ShowHoverMarker";
const QString GlobalSettings::Key_Dec_InitialStateConfigurable = "Dec_InitialStateConfigurable";
const QString GlobalSettings::Key_Log_BufferSize = "Log_BufferSize";
const QString GlobalSettings::Key_Log_NotifyOfStacktrace = "Log_NotifyOfStacktrace";
static const QString Key_View_ConversionThresholdDispMode;
static const QString Key_View_DefaultDivHeight;
static const QString Key_View_DefaultLogicHeight;
+ static const QString Key_View_ShowHoverMarker;
static const QString Key_Dec_InitialStateConfigurable;
static const QString Key_Log_BufferSize;
static const QString Key_Log_NotifyOfStacktrace;
connect(analog_data, SIGNAL(min_max_changed(float, float)),
this, SLOT(on_min_max_changed(float, float)));
- GlobalSettings::add_change_handler(this);
-
GlobalSettings gs;
conversion_threshold_disp_mode_ =
gs.value(GlobalSettings::Key_View_ConversionThresholdDispMode).toInt();
void AnalogSignal::on_setting_changed(const QString &key, const QVariant &value)
{
+ Signal::on_setting_changed(key, value);
+
if (key == GlobalSettings::Key_View_ConversionThresholdDispMode)
on_settingViewConversionThresholdDispMode_changed(value);
}
p.drawText(bounding_rect, Qt::AlignRight | Qt::AlignBottom, infotext);
}
+
+ if (show_hover_marker_)
+ paint_hover_marker(p);
}
void AnalogSignal::paint_grid(QPainter &p, int y, int left, int right)
#include <QComboBox>
#include <QSpinBox>
-#include <pv/globalsettings.hpp>
#include <pv/views/trace/signal.hpp>
using std::pair;
namespace views {
namespace trace {
-class AnalogSignal : public Signal, public GlobalSettingsInterface
+class AnalogSignal : public Signal
{
Q_OBJECT
*/
void scale_handle_drag_release();
- void on_setting_changed(const QString &key, const QVariant &value);
+ virtual void on_setting_changed(const QString &key, const QVariant &value);
/**
* Paints the background layer of the signal with a QPainter
p.setPen(QApplication::palette().color(QPalette::WindowText));
p.drawText(r, f, h);
}
+
+ if (show_hover_marker_)
+ paint_hover_marker(p);
}
void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
void LogicSignal::paint_fore(QPainter &p, ViewItemPaintParams &pp)
{
// Draw the trigger marker
- if (!trigger_match_ || !base_->enabled())
- return;
+ if (base_->enabled() && trigger_match_) {
+ const int y = get_visual_y();
+ const vector<int32_t> trig_types = get_trigger_types();
- const int y = get_visual_y();
- const vector<int32_t> trig_types = get_trigger_types();
- for (int32_t type_id : trig_types) {
- const TriggerMatchType *const type =
- TriggerMatchType::get(type_id);
- if (trigger_match_ != type || type_id < 0 ||
- (size_t)type_id >= countof(TriggerMarkerIcons) ||
- !TriggerMarkerIcons[type_id])
- continue;
-
- const QPixmap *const pixmap = get_pixmap(
- TriggerMarkerIcons[type_id]);
- if (!pixmap)
- continue;
-
- const float pad = TriggerMarkerPadding - 0.5f;
- const QSize size = pixmap->size();
- const QPoint point(
- pp.right() - size.width() - pad * 2,
- y - (signal_height_ + size.height()) / 2);
-
- p.setPen(QPen(TriggerMarkerBackgroundColor.darker()));
- p.setBrush(TriggerMarkerBackgroundColor);
- p.drawRoundedRect(QRectF(point, size).adjusted(
- -pad, -pad, pad, pad), pad, pad);
- p.drawPixmap(point, *pixmap);
-
- break;
+ for (int32_t type_id : trig_types) {
+ const TriggerMatchType *const type =
+ TriggerMatchType::get(type_id);
+ if (trigger_match_ != type || type_id < 0 ||
+ (size_t)type_id >= countof(TriggerMarkerIcons) ||
+ !TriggerMarkerIcons[type_id])
+ continue;
+
+ const QPixmap *const pixmap = get_pixmap(
+ TriggerMarkerIcons[type_id]);
+ if (!pixmap)
+ continue;
+
+ const float pad = TriggerMarkerPadding - 0.5f;
+ const QSize size = pixmap->size();
+ const QPoint point(
+ pp.right() - size.width() - pad * 2,
+ y - (signal_height_ + size.height()) / 2);
+
+ p.setPen(QPen(TriggerMarkerBackgroundColor.darker()));
+ p.setBrush(TriggerMarkerBackgroundColor);
+ p.drawRoundedRect(QRectF(point, size).adjusted(
+ -pad, -pad, pad, pad), pad, pad);
+ p.drawPixmap(point, *pixmap);
+
+ break;
+ }
}
+
+ if (show_hover_marker_)
+ paint_hover_marker(p);
}
void LogicSignal::paint_caps(QPainter &p, QLineF *const lines,
this, SLOT(on_name_changed(const QString&)));
connect(channel.get(), SIGNAL(color_changed(const QColor&)),
this, SLOT(on_color_changed(const QColor&)));
+
+ GlobalSettings::add_change_handler(this);
+
+ GlobalSettings settings;
+ show_hover_marker_ =
+ settings.value(GlobalSettings::Key_View_ShowHoverMarker).toBool();
}
shared_ptr<data::SignalBase> Trace::base() const
return base_;
}
+void Trace::set_segment_display_mode(SegmentDisplayMode mode)
+{
+ segment_display_mode_ = mode;
+
+ if (owner_)
+ owner_->row_item_appearance_changed(true, true);
+}
+
+void Trace::on_setting_changed(const QString &key, const QVariant &value)
+{
+ if (key == GlobalSettings::Key_View_ShowHoverMarker)
+ show_hover_marker_ = value.toBool();
+}
+
void Trace::paint_label(QPainter &p, const QRect &rect, bool hover)
{
const int y = get_visual_y();
return current_segment_;
}
+void Trace::hover_point_changed(const QPoint &hp)
+{
+ (void)hp;
+
+ if (owner_)
+ owner_->row_item_appearance_changed(false, true);
+}
+
void Trace::paint_back(QPainter &p, ViewItemPaintParams &pp)
{
const View *view = owner_->view();
form->addRow(tr("Color"), color_button);
}
+void Trace::paint_hover_marker(QPainter &p)
+{
+ const View *view = owner_->view();
+ assert(view);
+
+ const int x = view->hover_point().x();
+
+ if (x == -1)
+ return;
+
+ p.setPen(QPen(QColor(Qt::lightGray)));
+
+ const pair<int, int> extents = v_extents();
+
+ p.setRenderHint(QPainter::Antialiasing, false);
+ p.drawLine(x, get_visual_y() + extents.first,
+ x, get_visual_y() + extents.second);
+ p.setRenderHint(QPainter::Antialiasing, true);
+}
+
void Trace::create_popup_form()
{
// Clear the layout
add_color_option(parent, form);
}
-void Trace::set_segment_display_mode(SegmentDisplayMode mode)
-{
- segment_display_mode_ = mode;
-
- if (owner_)
- owner_->row_item_appearance_changed(true, true);
-}
-
void Trace::on_name_changed(const QString &text)
{
/* This event handler is called by SignalBase when the name was changed there */
#include "tracetreeitem.hpp"
+#include <pv/globalsettings.hpp>
#include "pv/data/signalbase.hpp"
using std::shared_ptr;
* For this reason, Trace is more generic and contains properties and helpers
* that benefit any kind of time series items.
*/
-class Trace : public TraceTreeItem
+class Trace : public TraceTreeItem, public GlobalSettingsInterface
{
Q_OBJECT
*/
virtual void set_segment_display_mode(SegmentDisplayMode mode);
+ virtual void on_setting_changed(const QString &key, const QVariant &value);
+
/**
* Paints the signal label.
* @param p the QPainter to paint into.
int get_current_segment() const;
+ virtual void hover_point_changed(const QPoint &hp);
+
protected:
/**
* Paints the background layer of the signal with a QPainter.
*/
void paint_axis(QPainter &p, ViewItemPaintParams &pp, int y);
+ /**
+ * Draw a hover marker under the cursor position.
+ * @param p The painter to draw into.
+ */
+ void paint_hover_marker(QPainter &p);
+
void add_color_option(QWidget *parent, QFormLayout *form);
void create_popup_form();
QPen axis_pen_;
SegmentDisplayMode segment_display_mode_;
+ bool show_hover_marker_;
/// The ID of the currently displayed segment
int current_segment_;