add more shortcuts to main window and graphing window
This commit is contained in:
+84
-6
@@ -9,6 +9,9 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
#define MOVE_FACTOR (1.0 / 2.0)
|
||||||
|
#define MOVE_FACTOR_FINE (1.0 / 10.0)
|
||||||
|
|
||||||
GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::GraphingWindow)
|
ui(new Ui::GraphingWindow)
|
||||||
@@ -112,6 +115,8 @@ GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent)
|
|||||||
|
|
||||||
needScaleSetup = true;
|
needScaleSetup = true;
|
||||||
followGraphEnd = true;
|
followGraphEnd = true;
|
||||||
|
xPressed = false;
|
||||||
|
yPressed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphingWindow::~GraphingWindow()
|
GraphingWindow::~GraphingWindow()
|
||||||
@@ -465,16 +470,47 @@ void GraphingWindow::mouseWheel()
|
|||||||
|
|
||||||
bool GraphingWindow::eventFilter(QObject *obj, QEvent *event)
|
bool GraphingWindow::eventFilter(QObject *obj, QEvent *event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::KeyRelease) {
|
if (event->type() == QEvent::KeyRelease || event->type() == QEvent::KeyPress) {
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
switch (keyEvent->key())
|
||||||
|
{
|
||||||
|
case Qt::Key_X:
|
||||||
|
xPressed = event->type() == QEvent::KeyPress;
|
||||||
|
break;
|
||||||
|
case Qt::Key_Y:
|
||||||
|
yPressed = event->type() == QEvent::KeyPress;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (event->type() != QEvent::KeyRelease)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch (keyEvent->key())
|
switch (keyEvent->key())
|
||||||
{
|
{
|
||||||
case Qt::Key_Plus:
|
case Qt::Key_Plus:
|
||||||
|
case Qt::Key_PageUp:
|
||||||
zoomIn();
|
zoomIn();
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Minus:
|
case Qt::Key_Minus:
|
||||||
|
case Qt::Key_PageDown:
|
||||||
zoomOut();
|
zoomOut();
|
||||||
break;
|
break;
|
||||||
|
case Qt::Key_Up:
|
||||||
|
moveUp(QApplication::keyboardModifiers() == Qt::ShiftModifier);
|
||||||
|
break;
|
||||||
|
case Qt::Key_Down:
|
||||||
|
moveDown(QApplication::keyboardModifiers() == Qt::ShiftModifier);
|
||||||
|
break;
|
||||||
|
case Qt::Key_Left:
|
||||||
|
moveLeft(QApplication::keyboardModifiers() == Qt::ShiftModifier);
|
||||||
|
break;
|
||||||
|
case Qt::Key_Right:
|
||||||
|
moveRight(QApplication::keyboardModifiers() == Qt::ShiftModifier);
|
||||||
|
break;
|
||||||
|
case Qt::Key_F:
|
||||||
|
toggleFollowMode();
|
||||||
|
break;
|
||||||
case Qt::Key_F1:
|
case Qt::Key_F1:
|
||||||
HelpWindow::getRef()->showHelp("graphwindow.md");
|
HelpWindow::getRef()->showHelp("graphwindow.md");
|
||||||
break;
|
break;
|
||||||
@@ -526,12 +562,12 @@ void GraphingWindow::zoomIn()
|
|||||||
{
|
{
|
||||||
QCPRange xrange = ui->graphingView->xAxis->range();
|
QCPRange xrange = ui->graphingView->xAxis->range();
|
||||||
QCPRange yrange = ui->graphingView->yAxis->range();
|
QCPRange yrange = ui->graphingView->yAxis->range();
|
||||||
if (ui->graphingView->xAxis->selectedParts().testFlag(QCPAxis::spAxis))
|
if (ui->graphingView->xAxis->selectedParts().testFlag(QCPAxis::spAxis) || xPressed)
|
||||||
{
|
{
|
||||||
ui->graphingView->xAxis->scaleRange(0.666, xrange.center());
|
ui->graphingView->xAxis->scaleRange(0.666, xrange.center());
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (ui->graphingView->yAxis->selectedParts().testFlag(QCPAxis::spAxis))
|
else if (ui->graphingView->yAxis->selectedParts().testFlag(QCPAxis::spAxis) || yPressed)
|
||||||
{
|
{
|
||||||
ui->graphingView->yAxis->scaleRange(0.666, yrange.center());
|
ui->graphingView->yAxis->scaleRange(0.666, yrange.center());
|
||||||
}
|
}
|
||||||
@@ -547,12 +583,12 @@ void GraphingWindow::zoomOut()
|
|||||||
{
|
{
|
||||||
QCPRange xrange = ui->graphingView->xAxis->range();
|
QCPRange xrange = ui->graphingView->xAxis->range();
|
||||||
QCPRange yrange = ui->graphingView->yAxis->range();
|
QCPRange yrange = ui->graphingView->yAxis->range();
|
||||||
if (ui->graphingView->xAxis->selectedParts().testFlag(QCPAxis::spAxis))
|
if (ui->graphingView->xAxis->selectedParts().testFlag(QCPAxis::spAxis) || xPressed)
|
||||||
{
|
{
|
||||||
ui->graphingView->xAxis->scaleRange(1.5, xrange.center());
|
ui->graphingView->xAxis->scaleRange(1.5, xrange.center());
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (ui->graphingView->yAxis->selectedParts().testFlag(QCPAxis::spAxis))
|
else if (ui->graphingView->yAxis->selectedParts().testFlag(QCPAxis::spAxis) || yPressed)
|
||||||
{
|
{
|
||||||
ui->graphingView->yAxis->scaleRange(1.5, yrange.center());
|
ui->graphingView->yAxis->scaleRange(1.5, yrange.center());
|
||||||
}
|
}
|
||||||
@@ -564,6 +600,47 @@ void GraphingWindow::zoomOut()
|
|||||||
ui->graphingView->replot();
|
ui->graphingView->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphingWindow::moveUp(bool fine)
|
||||||
|
{
|
||||||
|
QCPRange range = ui->graphingView->yAxis->range();
|
||||||
|
double diff = (range.upper - range.lower);
|
||||||
|
if (fine) diff *= MOVE_FACTOR_FINE;
|
||||||
|
else diff *= MOVE_FACTOR;
|
||||||
|
ui->graphingView->yAxis->moveRange(diff);
|
||||||
|
ui->graphingView->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphingWindow::moveDown(bool fine)
|
||||||
|
{
|
||||||
|
QCPRange range = ui->graphingView->yAxis->range();
|
||||||
|
double diff = (range.upper - range.lower);
|
||||||
|
if (fine) diff *= MOVE_FACTOR_FINE;
|
||||||
|
else diff *= MOVE_FACTOR;
|
||||||
|
ui->graphingView->yAxis->moveRange(-diff);
|
||||||
|
ui->graphingView->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphingWindow::moveLeft(bool fine)
|
||||||
|
{
|
||||||
|
QCPRange range = ui->graphingView->xAxis->range();
|
||||||
|
double diff = (range.upper - range.lower);
|
||||||
|
if (fine) diff *= MOVE_FACTOR_FINE;
|
||||||
|
else diff *= MOVE_FACTOR;
|
||||||
|
ui->graphingView->xAxis->moveRange(-diff);
|
||||||
|
ui->graphingView->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphingWindow::moveRight(bool fine)
|
||||||
|
{
|
||||||
|
QCPRange range = ui->graphingView->xAxis->range();
|
||||||
|
double diff = (range.upper - range.lower);
|
||||||
|
if (fine) diff *= MOVE_FACTOR_FINE;
|
||||||
|
else diff *= MOVE_FACTOR;
|
||||||
|
ui->graphingView->xAxis->moveRange(diff);
|
||||||
|
ui->graphingView->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphingWindow::removeSelectedGraph()
|
void GraphingWindow::removeSelectedGraph()
|
||||||
{
|
{
|
||||||
if (ui->graphingView->selectedGraphs().size() > 0)
|
if (ui->graphingView->selectedGraphs().size() > 0)
|
||||||
@@ -671,7 +748,8 @@ void GraphingWindow::contextMenuRequest(QPoint pos)
|
|||||||
menu->addAction(tr("Save graph definitions to file"), this, SLOT(saveDefinitions()));
|
menu->addAction(tr("Save graph definitions to file"), this, SLOT(saveDefinitions()));
|
||||||
menu->addAction(tr("Load graph definitions from file"), this, SLOT(loadDefinitions()));
|
menu->addAction(tr("Load graph definitions from file"), this, SLOT(loadDefinitions()));
|
||||||
menu->addAction(tr("Save spreadsheet of data"), this, SLOT(saveSpreadsheet()));
|
menu->addAction(tr("Save spreadsheet of data"), this, SLOT(saveSpreadsheet()));
|
||||||
QAction *act = menu->addAction(tr("Follow end of graph"), this, SLOT(toggleFollowMode()));
|
QKeySequence followShortcut = QKeySequence("F");
|
||||||
|
QAction *act = menu->addAction(tr("Follow end of graph"), this, SLOT(toggleFollowMode()), followShortcut);
|
||||||
act->setCheckable(true);
|
act->setCheckable(true);
|
||||||
act->setChecked(followGraphEnd);
|
act->setChecked(followGraphEnd);
|
||||||
menu->addAction(tr("Add new graph"), this, SLOT(addNewGraph()));
|
menu->addAction(tr("Add new graph"), this, SLOT(addNewGraph()));
|
||||||
|
|||||||
@@ -87,6 +87,10 @@ private slots:
|
|||||||
void resetView();
|
void resetView();
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
void zoomOut();
|
void zoomOut();
|
||||||
|
void moveUp(bool fine);
|
||||||
|
void moveDown(bool fine);
|
||||||
|
void moveLeft(bool fine);
|
||||||
|
void moveRight(bool fine);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sendCenterTimeID(uint32_t ID, double timestamp);
|
void sendCenterTimeID(uint32_t ID, double timestamp);
|
||||||
@@ -104,6 +108,8 @@ private:
|
|||||||
bool needScaleSetup; //do we need to set x,y graphing extents?
|
bool needScaleSetup; //do we need to set x,y graphing extents?
|
||||||
bool useOpenGL;
|
bool useOpenGL;
|
||||||
bool followGraphEnd;
|
bool followGraphEnd;
|
||||||
|
bool xPressed;
|
||||||
|
bool yPressed;
|
||||||
|
|
||||||
void showParamsDialog(int idx);
|
void showParamsDialog(int idx);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|||||||
@@ -461,6 +461,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Playback</string>
|
<string>Playback</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+P</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_Custom">
|
<action name="action_Custom">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -481,6 +484,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>New Graphing Window</string>
|
<string>New Graphing Window</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+G</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionOpen_Log_File">
|
<action name="actionOpen_Log_File">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -494,6 +500,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save Log File</string>
|
<string>Save Log File</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+S</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionFrame_Data_Analysis">
|
<action name="actionFrame_Data_Analysis">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -534,6 +543,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Preferences</string>
|
<string>Preferences</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+,</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSave_Filtered_Log_File">
|
<action name="actionSave_Filtered_Log_File">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -559,6 +571,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Open Connection Window</string>
|
<string>Open Connection Window</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+Shift+C</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionConnect">
|
<action name="actionConnect">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -584,6 +599,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>DBC File Manager</string>
|
<string>DBC File Manager</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+D</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionFuzzing">
|
<action name="actionFuzzing">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|||||||
Reference in New Issue
Block a user