Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pan plots with arrow keys #1045

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions plotjuggler_base/src/plotpanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "plotpanner.h"

#include <QKeyEvent>

void PlotPanner::moveCanvas(int dx, int dy)
{
if (dx == 0 && dy == 0)
Expand Down Expand Up @@ -61,3 +63,15 @@ void PlotPanner::moveCanvas(int dx, int dy)
plot->setAutoReplot(doAutoReplot);
plot->replot();
}

void PlotPanner::widgetKeyPressEvent(QKeyEvent* ke)
{
if(ke->key() == Qt::Key_Right)
moveCanvas(-10,0);
else if(ke->key() == Qt::Key_Left)
moveCanvas(10,0);
else if(ke->key() == Qt::Key_Up)
moveCanvas(0,10);
else if(ke->key() == Qt::Key_Down)
moveCanvas(0,-10);
}
2 changes: 2 additions & 0 deletions plotjuggler_base/src/plotpanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class PlotPanner : public QwtPlotPanner
public Q_SLOTS:
void moveCanvas(int dx, int dy) override;

void widgetKeyPressEvent(QKeyEvent* ke) override;

signals:
void rescaled(QRectF new_size);

Expand Down
Loading