QString::fromUtf8("actionViewZoomFit"));
menu_view->addAction(action_view_zoom_fit);
+ QAction *const action_view_zoom_one_to_one = new QAction(this);
+ action_view_zoom_one_to_one->setText(QApplication::translate(
+ "MainWindow", "Zoom to &One-to-One", 0,
+ QApplication::UnicodeUTF8));
+ action_view_zoom_one_to_one->setIcon(QIcon::fromTheme("zoom-original",
+ QIcon(":/icons/zoom-original.png")));
+ action_view_zoom_one_to_one->setShortcut(QKeySequence(Qt::Key_O));
+ action_view_zoom_one_to_one->setObjectName(
+ QString::fromUtf8("actionViewZoomOneToOne"));
+ menu_view->addAction(action_view_zoom_one_to_one);
+
menu_view->addSeparator();
QAction *action_view_show_cursors = new QAction(this);
_view->zoom_fit();
}
+void MainWindow::on_actionViewZoomOneToOne_triggered()
+{
+ _view->zoom_one_to_one();
+}
+
void MainWindow::on_actionViewShowCursors_triggered()
{
assert(_view);
void View::zoom(double steps, int offset)
{
- const double cursor_offset = _offset + _scale * offset;
const double new_scale = max(min(_scale * pow(3.0/2.0, -steps),
MaxScale), MinScale);
- const double new_offset = cursor_offset - new_scale * offset;
- set_scale_offset(new_scale, new_offset);
+ set_zoom(new_scale, offset);
}
void View::zoom_fit()
set_scale_offset((right_time - left_time) / w, left_time);
}
+void View::zoom_one_to_one()
+{
+ using pv::data::SignalData;
+
+ const vector< shared_ptr<Signal> > sigs(
+ session().get_signals());
+
+ // Make a set of all the visible data objects
+ set< shared_ptr<SignalData> > visible_data;
+ BOOST_FOREACH(const shared_ptr<Signal> sig, sigs)
+ if (sig->enabled())
+ visible_data.insert(sig->data());
+
+ if (visible_data.empty())
+ return;
+
+ double samplerate = 0.0;
+ BOOST_FOREACH(const shared_ptr<SignalData> d, visible_data) {
+ assert(d);
+ samplerate = max(samplerate, d->samplerate());
+ }
+
+ if (samplerate == 0.0)
+ return;
+
+ assert(_viewport);
+ const int w = _viewport->width();
+ if (w <= 0)
+ return;
+
+ set_zoom(1.0 / samplerate, w / 2);
+}
+
void View::set_scale_offset(double scale, double offset)
{
_scale = scale;
offset = _offset / _scale;
}
+void View::set_zoom(double scale, int offset)
+{
+ const double cursor_offset = _offset + _scale * offset;
+ const double new_scale = max(min(scale, MaxScale), MinScale);
+ const double new_offset = cursor_offset - new_scale * offset;
+ set_scale_offset(new_scale, new_offset);
+}
+
void View::update_scroll()
{
assert(_viewport);
void zoom_fit();
+ void zoom_one_to_one();
+
/**
* Sets the scale and offset.
* @param scale The new view scale in seconds per pixel.
private:
void get_scroll_layout(double &length, double &offset) const;
+ void set_zoom(double scale, int offset);
+
void update_scroll();
static bool compare_trace_v_offsets(