Added ability to save an image of the graph, fixed graphing so that timing is relative to the start of the capture (this makes viewing one capture after another with the same graphs much easier). Fixed rescale when importing a new file (no longer rescales).

The bottom line is that it'll be a lot easier to work with graphing of multiple files now.
This commit is contained in:
Collin Kidder
2015-06-07 22:41:57 -04:00
parent baf6b0e6c1
commit 1b67ac5cf4
3 changed files with 41 additions and 7 deletions
+37 -4
View File
@@ -84,7 +84,7 @@ void GraphingWindow::updatedFrames(int numFrames)
//there shouldn't be any need to actually remove the graphs. //there shouldn't be any need to actually remove the graphs.
//regenerate them instead //regenerate them instead
ui->graphingView->clearGraphs(); //temporarily remove the graphs from the graph view ui->graphingView->clearGraphs(); //temporarily remove the graphs from the graph view
needScaleSetup = true; //needScaleSetup = true;
for (int i = 0; i < graphParams.count(); i++) for (int i = 0; i < graphParams.count(); i++)
{ {
createGraph(graphParams[i], false); //regenerate each one createGraph(graphParams[i], false); //regenerate each one
@@ -96,8 +96,6 @@ void GraphingWindow::updatedFrames(int numFrames)
} }
} }
void GraphingWindow::titleDoubleClick(QMouseEvent* event, QCPPlotTitle* title) void GraphingWindow::titleDoubleClick(QMouseEvent* event, QCPPlotTitle* title)
{ {
Q_UNUSED(event) Q_UNUSED(event)
@@ -277,8 +275,10 @@ void GraphingWindow::contextMenuRequest(QPoint pos)
menu->addAction(tr("Move to top right"), this, SLOT(moveLegend()))->setData((int)(Qt::AlignTop|Qt::AlignRight)); menu->addAction(tr("Move to top right"), this, SLOT(moveLegend()))->setData((int)(Qt::AlignTop|Qt::AlignRight));
menu->addAction(tr("Move to bottom right"), this, SLOT(moveLegend()))->setData((int)(Qt::AlignBottom|Qt::AlignRight)); menu->addAction(tr("Move to bottom right"), this, SLOT(moveLegend()))->setData((int)(Qt::AlignBottom|Qt::AlignRight));
menu->addAction(tr("Move to bottom left"), this, SLOT(moveLegend()))->setData((int)(Qt::AlignBottom|Qt::AlignLeft)); menu->addAction(tr("Move to bottom left"), this, SLOT(moveLegend()))->setData((int)(Qt::AlignBottom|Qt::AlignLeft));
} else // general context menu on graphs requested }
else // general context menu on graphs requested
{ {
menu->addAction(tr("Save Graphs to File"), this, SLOT(saveGraphs()));
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)
{ {
@@ -292,6 +292,31 @@ void GraphingWindow::contextMenuRequest(QPoint pos)
menu->popup(ui->graphingView->mapToGlobal(pos)); menu->popup(ui->graphingView->mapToGlobal(pos));
} }
void GraphingWindow::saveGraphs()
{
QString filename;
QFileDialog dialog(this);
QStringList filters;
filters.append(QString(tr("PDF Files (*.pdf)")));
filters.append(QString(tr("PNG Files (*.png)")));
filters.append(QString(tr("JPEG Files (*.jpg)")));
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setNameFilters(filters);
dialog.setViewMode(QFileDialog::Detail);
dialog.setAcceptMode(QFileDialog::AcceptSave);
if (dialog.exec() == QDialog::Accepted)
{
filename = dialog.selectedFiles()[0];
if (dialog.selectedNameFilter() == filters[0]) ui->graphingView->savePdf(filename, true, 0, 0);
if (dialog.selectedNameFilter() == filters[1]) ui->graphingView->savePng(filename, 0, 0);
if (dialog.selectedNameFilter() == filters[2]) ui->graphingView->saveJpg(filename, 0, 0);
}
}
void GraphingWindow::showParamsDialog(int idx = -1) void GraphingWindow::showParamsDialog(int idx = -1)
{ {
NewGraphDialog *thisDialog = new NewGraphDialog(); NewGraphDialog *thisDialog = new NewGraphDialog();
@@ -419,6 +444,14 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
if (x[j] > xmaxval) xmaxval = x[j]; if (x[j] > xmaxval) xmaxval = x[j];
} }
} }
for (int ct = 0; ct < x.count(); ct++)
{
x[ct] -= xminval;
}
xmaxval -= xminval;
xminval = 0;
ui->graphingView->addGraph(); ui->graphingView->addGraph();
params.ref = ui->graphingView->graph(); params.ref = ui->graphingView->graph();
if (createGraphParam) graphParams.append(params); if (createGraphParam) graphParams.append(params);
+1
View File
@@ -44,6 +44,7 @@ private slots:
void removeAllGraphs(); void removeAllGraphs();
void contextMenuRequest(QPoint pos); void contextMenuRequest(QPoint pos);
void moveLegend(); void moveLegend();
void saveGraphs();
void addNewGraph(); void addNewGraph();
void createGraph(GraphParams &params, bool createGraphParam = true); void createGraph(GraphParams &params, bool createGraphParam = true);
void editSelectedGraph(); void editSelectedGraph();
+1 -1
View File
@@ -14,7 +14,7 @@
#include "dbchandler.h" #include "dbchandler.h"
#include "dbcmaineditor.h" #include "dbcmaineditor.h"
#define VERSION 110 #define VERSION 111
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;