SLOT(on_view_zoomToFitAfterAcq_changed(int)));
trace_view_layout->addRow(tr("Perform a zoom-to-&fit when acquisition stops"), cb);
+ cb = create_checkbox(GlobalSettings::Key_View_TriggerIsZeroTime,
+ SLOT(on_view_triggerIsZero_changed(int)));
+ trace_view_layout->addRow(tr("Show time zero at the trigger"), cb);
+
cb = create_checkbox(GlobalSettings::Key_View_StickyScrolling,
SLOT(on_view_stickyScrolling_changed(int)));
trace_view_layout->addRow(tr("Always keep &newest samples at the right edge during capture"), cb);
settings.setValue(GlobalSettings::Key_View_ZoomToFitAfterAcq, state ? true : false);
}
+void Settings::on_view_triggerIsZero_changed(int state)
+{
+ GlobalSettings settings;
+ settings.setValue(GlobalSettings::Key_View_TriggerIsZeroTime, state ? true : false);
+}
+
void Settings::on_view_colouredBG_changed(int state)
{
GlobalSettings settings;
void on_page_changed(QListWidgetItem *current, QListWidgetItem *previous);
void on_view_zoomToFitDuringAcq_changed(int state);
void on_view_zoomToFitAfterAcq_changed(int state);
+ void on_view_triggerIsZero_changed(int state);
void on_view_colouredBG_changed(int state);
void on_view_stickyScrolling_changed(int state);
void on_view_showSamplingPoints_changed(int state);
const QString GlobalSettings::Key_View_ZoomToFitDuringAcq = "View_ZoomToFitDuringAcq";
const QString GlobalSettings::Key_View_ZoomToFitAfterAcq = "View_ZoomToFitAfterAcq";
+const QString GlobalSettings::Key_View_TriggerIsZeroTime = "View_TriggerIsZeroTime";
const QString GlobalSettings::Key_View_ColouredBG = "View_ColouredBG";
const QString GlobalSettings::Key_View_StickyScrolling = "View_StickyScrolling";
const QString GlobalSettings::Key_View_ShowSamplingPoints = "View_ShowSamplingPoints";
public:
static const QString Key_View_ZoomToFitDuringAcq;
static const QString Key_View_ZoomToFitAfterAcq;
+ static const QString Key_View_TriggerIsZeroTime;
static const QString Key_View_ColouredBG;
static const QString Key_View_StickyScrolling;
static const QString Key_View_ShowSamplingPoints;
tick_position_cache_ = calculate_tick_positions(
view_.tick_period(),
- view_.offset(),
+ view_.ruler_offset(),
view_.scale(),
width(),
ffunc);
void Ruler::mouseDoubleClickEvent(QMouseEvent *event)
{
- view_.add_flag(view_.offset() + ((double)event->x() + 0.5) * view_.scale());
+ view_.add_flag(view_.ruler_offset() + ((double)event->x() + 0.5) * view_.scale());
}
void Ruler::draw_hover_mark(QPainter &p, int text_height)
* Calculates the major and minor tick positions.
*
* @param major_period The period between the major ticks.
- * @param offset The time at the left border of the ruler.
+ * @param offset The virtual time at the left border of the ruler.
* @param scale The scale in seconds per pixel.
* @param width the Width of the ruler.
* @param format_function A function used to format the major tick times.
segment_selectable_(false),
scale_(1e-3),
offset_(0),
+ ruler_offset_(0),
updating_scroll_(false),
settings_restored_(false),
header_was_shrunk_(false),
settings.setValue("splitter_state", splitter_->saveState());
settings.setValue("segment_display_mode", segment_display_mode_);
- stringstream ss;
- boost::archive::text_oarchive oa(ss);
- oa << boost::serialization::make_nvp("offset", offset_);
- settings.setValue("offset", QString::fromStdString(ss.str()));
+ {
+ stringstream ss;
+ boost::archive::text_oarchive oa(ss);
+ oa << boost::serialization::make_nvp("ruler_shift", ruler_shift_);
+ settings.setValue("ruler_shift", QString::fromStdString(ss.str()));
+ }
+ {
+ stringstream ss;
+ boost::archive::text_oarchive oa(ss);
+ oa << boost::serialization::make_nvp("offset", offset_);
+ settings.setValue("offset", QString::fromStdString(ss.str()));
+ }
for (shared_ptr<Signal> signal : signals_) {
settings.beginGroup(signal->base()->internal_name());
if (settings.contains("scale"))
set_scale(settings.value("scale").toDouble());
+ if (settings.contains("ruler_shift")) {
+ util::Timestamp shift;
+ stringstream ss;
+ ss << settings.value("ruler_shift").toString().toStdString();
+
+ boost::archive::text_iarchive ia(ss);
+ ia >> boost::serialization::make_nvp("ruler_shift", shift);
+
+ ruler_shift_ = shift;
+ }
+
if (settings.contains("offset")) {
util::Timestamp offset;
stringstream ss;
boost::archive::text_iarchive ia(ss);
ia >> boost::serialization::make_nvp("offset", offset);
+ // This also updates ruler_offset_
set_offset(offset);
}
}
}
-const Timestamp& View::offset() const
-{
- return offset_;
-}
-
void View::set_offset(const pv::util::Timestamp& offset)
{
if (offset_ != offset) {
offset_ = offset;
+ ruler_offset_ = offset_ + ruler_shift_;
offset_changed();
}
}
+// Returns the internal version of the time offset
+const Timestamp& View::offset() const
+{
+ return offset_;
+}
+
+// Returns the ruler version of the time offset
+const Timestamp& View::ruler_offset() const
+{
+ return ruler_offset_;
+}
+
int View::owner_visual_v_offset() const
{
return -scrollarea_->verticalScrollBar()->sliderPosition();
void View::trigger_event(util::Timestamp location)
{
+ // Set up ruler_shift if the Key_View_TriggerIsZeroTime option is set.
+ GlobalSettings settings;
+ bool trigger_is_zero_time = settings.value(GlobalSettings::Key_View_TriggerIsZeroTime).toBool();
+
+ ruler_shift_ = (trigger_is_zero_time) ? (-location) : (0);
+ // Force an immediate update of both offsets
+ offset_ -= 0.001;
+ set_offset(offset_ + 0.001);
+
trigger_markers_.push_back(make_shared<TriggerMarker>(*this, location));
}
double scale() const;
/**
- * Returns the time offset of the left edge of the view in
- * seconds.
+ * Returns the internal view version of the time offset of the left edge
+ * of the view in seconds.
*/
const pv::util::Timestamp& offset() const;
+ /**
+ * Returns the ruler version of the time offset of the left edge
+ * of the view in seconds.
+ */
+ const pv::util::Timestamp& ruler_offset() const;
+
/**
* Returns the vertical scroll offset.
*/
void process_sticky_events();
/**
- * Sets the 'offset_' member and emits the 'offset_changed'
+ * Sets the 'offset_' and ruler_offset_ members and emits the 'offset_changed'
* signal if needed.
*/
void set_offset(const pv::util::Timestamp& offset);
/// The view time scale in seconds per pixel.
double scale_;
- /// The view time offset in seconds.
+ /// The internal view version of the time offset in seconds.
pv::util::Timestamp offset_;
+ /// The ruler version of the time offset in seconds.
+ pv::util::Timestamp ruler_offset_;
bool updating_scroll_;
bool settings_restored_;
ViewBase::ViewBase(Session &session, bool is_main_view, QWidget *parent) :
session_(session),
is_main_view_(is_main_view),
+ ruler_shift_(0),
current_segment_(0)
{
(void)parent;
const bool is_main_view_;
+ util::Timestamp ruler_shift_;
util::TimeUnit time_unit_;
unordered_set< shared_ptr<data::SignalBase> > signalbases_;