Added more control options to graphing window, updated version number
The graphing window now can be zoomed via the context menu or with the + and - keys. Also, you can reset to a "good" view of all the graphs from the context menu.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#ifndef CONFIG
|
#ifndef CONFIG
|
||||||
#define CONFIG
|
#define CONFIG
|
||||||
|
|
||||||
#define VERSION 139
|
#define VERSION 140
|
||||||
|
|
||||||
//try to keep this in sync.
|
//try to keep this in sync.
|
||||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
//SavvyCAN will complain if you connect a GVRET board with a revision
|
||||||
|
|||||||
+4
-2
@@ -87,14 +87,14 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
|
|||||||
connect(ui->flowView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequestFlow(QPoint)));
|
connect(ui->flowView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequestFlow(QPoint)));
|
||||||
|
|
||||||
playbackTimer->setInterval(ui->spinPlayback->value()); //set the timer to the default value of the control
|
playbackTimer->setInterval(ui->spinPlayback->value()); //set the timer to the default value of the control
|
||||||
|
|
||||||
installEventFilter(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlowViewWindow::showEvent(QShowEvent* event)
|
void FlowViewWindow::showEvent(QShowEvent* event)
|
||||||
{
|
{
|
||||||
QDialog::showEvent(event);
|
QDialog::showEvent(event);
|
||||||
|
|
||||||
|
installEventFilter(this);
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
refreshIDList();
|
refreshIDList();
|
||||||
@@ -109,6 +109,8 @@ void FlowViewWindow::showEvent(QShowEvent* event)
|
|||||||
|
|
||||||
FlowViewWindow::~FlowViewWindow()
|
FlowViewWindow::~FlowViewWindow()
|
||||||
{
|
{
|
||||||
|
removeEventFilter(this);
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
|
|
||||||
playbackTimer->stop();
|
playbackTimer->stop();
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ GraphingWindow::~GraphingWindow()
|
|||||||
void GraphingWindow::showEvent(QShowEvent* event)
|
void GraphingWindow::showEvent(QShowEvent* event)
|
||||||
{
|
{
|
||||||
QDialog::showEvent(event);
|
QDialog::showEvent(event);
|
||||||
|
installEventFilter(this);
|
||||||
readSettings();
|
readSettings();
|
||||||
ui->graphingView->replot();
|
ui->graphingView->replot();
|
||||||
}
|
}
|
||||||
@@ -83,6 +84,7 @@ void GraphingWindow::showEvent(QShowEvent* event)
|
|||||||
void GraphingWindow::closeEvent(QCloseEvent *event)
|
void GraphingWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
removeEventFilter(this);
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,6 +308,90 @@ void GraphingWindow::mouseWheel()
|
|||||||
ui->graphingView->axisRect()->setRangeZoom(Qt::Horizontal|Qt::Vertical);
|
ui->graphingView->axisRect()->setRangeZoom(Qt::Horizontal|Qt::Vertical);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GraphingWindow::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::KeyRelease) {
|
||||||
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
switch (keyEvent->key())
|
||||||
|
{
|
||||||
|
case Qt::Key_Plus:
|
||||||
|
zoomIn();
|
||||||
|
break;
|
||||||
|
case Qt::Key_Minus:
|
||||||
|
zoomOut();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// standard event processing
|
||||||
|
return QObject::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphingWindow::resetView()
|
||||||
|
{
|
||||||
|
double yminval=10000000.0, ymaxval = -1000000.0;
|
||||||
|
double xminval=10000000000.0, xmaxval = -10000000000.0;
|
||||||
|
for (int i = 0; i < graphParams.count(); i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < graphParams[i].x.count(); j++)
|
||||||
|
{
|
||||||
|
if (graphParams[i].x[j] < xminval) xminval = graphParams[i].x[j];
|
||||||
|
if (graphParams[i].x[j] > xmaxval) xmaxval = graphParams[i].x[j];
|
||||||
|
if (graphParams[i].y[j] < yminval) yminval = graphParams[i].y[j];
|
||||||
|
if (graphParams[i].y[j] > ymaxval) ymaxval = graphParams[i].y[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->graphingView->xAxis->setRange(xminval, xmaxval);
|
||||||
|
ui->graphingView->yAxis->setRange(yminval, ymaxval);
|
||||||
|
ui->graphingView->axisRect()->setupFullAxesBox();
|
||||||
|
|
||||||
|
ui->graphingView->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphingWindow::zoomIn()
|
||||||
|
{
|
||||||
|
QCPRange xrange = ui->graphingView->xAxis->range();
|
||||||
|
QCPRange yrange = ui->graphingView->yAxis->range();
|
||||||
|
if (ui->graphingView->xAxis->selectedParts().testFlag(QCPAxis::spAxis))
|
||||||
|
{
|
||||||
|
ui->graphingView->xAxis->scaleRange(0.666, xrange.center());
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (ui->graphingView->yAxis->selectedParts().testFlag(QCPAxis::spAxis))
|
||||||
|
{
|
||||||
|
ui->graphingView->yAxis->scaleRange(0.666, yrange.center());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->graphingView->xAxis->scaleRange(0.666, xrange.center());
|
||||||
|
ui->graphingView->yAxis->scaleRange(0.666, yrange.center());
|
||||||
|
}
|
||||||
|
ui->graphingView->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphingWindow::zoomOut()
|
||||||
|
{
|
||||||
|
QCPRange xrange = ui->graphingView->xAxis->range();
|
||||||
|
QCPRange yrange = ui->graphingView->yAxis->range();
|
||||||
|
if (ui->graphingView->xAxis->selectedParts().testFlag(QCPAxis::spAxis))
|
||||||
|
{
|
||||||
|
ui->graphingView->xAxis->scaleRange(1.5, xrange.center());
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (ui->graphingView->yAxis->selectedParts().testFlag(QCPAxis::spAxis))
|
||||||
|
{
|
||||||
|
ui->graphingView->yAxis->scaleRange(1.5, yrange.center());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->graphingView->xAxis->scaleRange(1.5, xrange.center());
|
||||||
|
ui->graphingView->yAxis->scaleRange(1.5, yrange.center());
|
||||||
|
}
|
||||||
|
ui->graphingView->replot();
|
||||||
|
}
|
||||||
|
|
||||||
void GraphingWindow::removeSelectedGraph()
|
void GraphingWindow::removeSelectedGraph()
|
||||||
{
|
{
|
||||||
if (ui->graphingView->selectedGraphs().size() > 0)
|
if (ui->graphingView->selectedGraphs().size() > 0)
|
||||||
@@ -386,11 +472,19 @@ void GraphingWindow::contextMenuRequest(QPoint pos)
|
|||||||
menu->addAction(tr("Add new graph"), this, SLOT(addNewGraph()));
|
menu->addAction(tr("Add new graph"), this, SLOT(addNewGraph()));
|
||||||
if (ui->graphingView->selectedGraphs().size() > 0)
|
if (ui->graphingView->selectedGraphs().size() > 0)
|
||||||
{
|
{
|
||||||
|
menu->addSeparator();
|
||||||
menu->addAction(tr("Edit selected graph"), this, SLOT(editSelectedGraph()));
|
menu->addAction(tr("Edit selected graph"), this, SLOT(editSelectedGraph()));
|
||||||
menu->addAction(tr("Remove selected graph"), this, SLOT(removeSelectedGraph()));
|
menu->addAction(tr("Remove selected graph"), this, SLOT(removeSelectedGraph()));
|
||||||
}
|
}
|
||||||
if (ui->graphingView->graphCount() > 0)
|
if (ui->graphingView->graphCount() > 0)
|
||||||
|
{
|
||||||
|
menu->addSeparator();
|
||||||
menu->addAction(tr("Remove all graphs"), this, SLOT(removeAllGraphs()));
|
menu->addAction(tr("Remove all graphs"), this, SLOT(removeAllGraphs()));
|
||||||
|
}
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addAction(tr("Reset View"), this, SLOT(resetView()));
|
||||||
|
menu->addAction(tr("Zoom In"), this, SLOT(zoomIn()));
|
||||||
|
menu->addAction(tr("Zoom Out"), this, SLOT(zoomOut()));
|
||||||
}
|
}
|
||||||
|
|
||||||
menu->popup(ui->graphingView->mapToGlobal(pos));
|
menu->popup(ui->graphingView->mapToGlobal(pos));
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ private slots:
|
|||||||
void editSelectedGraph();
|
void editSelectedGraph();
|
||||||
void updatedFrames(int);
|
void updatedFrames(int);
|
||||||
void gotCenterTimeID(int32_t ID, double timestamp);
|
void gotCenterTimeID(int32_t ID, double timestamp);
|
||||||
|
void resetView();
|
||||||
|
void zoomIn();
|
||||||
|
void zoomOut();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sendCenterTimeID(int32_t ID, double timestamp);
|
void sendCenterTimeID(int32_t ID, double timestamp);
|
||||||
@@ -78,6 +81,7 @@ private:
|
|||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GRAPHINGWINDOW_H
|
#endif // GRAPHINGWINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user