Implementation of refresh on file load and frame clearing for Graphing window. Clear old frames when loading new file. Updated version.

This commit is contained in:
Collin Kidder
2015-06-03 22:45:16 -04:00
parent 97f7db4e62
commit 74c19d2c89
4 changed files with 38 additions and 6 deletions
+30 -2
View File
@@ -1,6 +1,7 @@
#include "graphingwindow.h"
#include "ui_graphingwindow.h"
#include "newgraphdialog.h"
#include "mainwindow.h"
#include <QDebug>
GraphingWindow::GraphingWindow(QVector<CANFrame> *frames, QWidget *parent) :
@@ -47,6 +48,8 @@ GraphingWindow::GraphingWindow(QVector<CANFrame> *frames, QWidget *parent) :
connect(ui->graphingView, SIGNAL(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)), this, SLOT(axisLabelDoubleClick(QCPAxis*,QCPAxis::SelectablePart)));
connect(ui->graphingView, SIGNAL(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this, SLOT(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*)));
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
// setup policy and connect slot for context menu popup:
ui->graphingView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->graphingView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));
@@ -63,8 +66,33 @@ GraphingWindow::~GraphingWindow()
void GraphingWindow::showEvent(QShowEvent* event)
{
QDialog::showEvent(event);
ui->graphingView->replot();
}
void GraphingWindow::updatedFrames(int numFrames)
{
if (numFrames == -1) //all frames deleted. Kill the display
{
removeAllGraphs();
}
else if (numFrames == -2) //all new set of frames. Reset
{
//there shouldn't be any need to actually remove the graphs.
//regenerate them instead
ui->graphingView->clearGraphs(); //temporarily remove the graphs from the graph view
for (int i = 0; i < graphParams.count(); i++)
{
createGraph(graphParams[i], false); //regenerate each one
}
ui->graphingView->replot(); //now, redisplay them all
}
else //just got some new frames. See if they are relevant.
{
}
}
void GraphingWindow::titleDoubleClick(QMouseEvent* event, QCPPlotTitle* title)
{
Q_UNUSED(event)
@@ -279,7 +307,7 @@ void GraphingWindow::addNewGraph()
showParamsDialog(-1);
}
void GraphingWindow::createGraph(GraphParams &params)
void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
{
int tempVal;
float minval=1000000, maxval = -100000;
@@ -376,7 +404,7 @@ void GraphingWindow::createGraph(GraphParams &params)
}
ui->graphingView->addGraph();
params.ref = ui->graphingView->graph();
graphParams.append(params);
if (createGraphParam) graphParams.append(params);
ui->graphingView->graph()->setSelectedBrush(Qt::NoBrush);
ui->graphingView->graph()->setSelectedPen(selectedPen);
ui->graphingView->graph()->setName(QString("Graph %1").arg(ui->graphingView->graphCount()-1));
+2 -1
View File
@@ -45,8 +45,9 @@ private slots:
void contextMenuRequest(QPoint pos);
void moveLegend();
void addNewGraph();
void createGraph(GraphParams &params);
void createGraph(GraphParams &params, bool createGraphParam = true);
void editSelectedGraph();
void updatedFrames(int);
private:
Ui::GraphingWindow *ui;
+5 -2
View File
@@ -557,8 +557,8 @@ void MainWindow::loadLogFile(QString filename)
{
QList<QByteArray> tokens = line.split(' ');
QList<QByteArray> timeToks = tokens[0].split(':');
timeStamp = (timeToks[0].toInt() * (1000 * 1000 * 60 * 60)) + (timeToks[1].toInt() * (1000 * 1000 * 60))
+ (timeToks[2].toInt() * (1000 * 1000)) + (timeToks[3].toInt() * 100);
timeStamp = (timeToks[0].toInt() * (1000ul * 1000ul * 60ul * 60ul)) + (timeToks[1].toInt() * (1000ul * 1000ul * 60ul))
+ (timeToks[2].toInt() * (1000ul * 1000ul)) + (timeToks[3].toInt() * 100ul);
thisFrame.timestamp = timeStamp;
thisFrame.ID = tokens[3].right(tokens[3].length() - 2).toInt(NULL, 16);
if (tokens[4] == "s") thisFrame.extended = false;
@@ -670,6 +670,9 @@ void MainWindow::handleLoadFile()
filename = dialog.selectedFiles()[0];
}
ui->canFramesView->scrollToTop();
model->clearFrames();
if (dialog.selectedNameFilter() == filters[0]) loadCRTDFile(filename);
if (dialog.selectedNameFilter() == filters[1]) loadNativeCSVFile(filename);
if (dialog.selectedNameFilter() == filters[2]) loadGenericCSVFile(filename);
+1 -1
View File
@@ -14,7 +14,7 @@
#include "dbchandler.h"
#include "dbcmaineditor.h"
#define VERSION 107
#define VERSION 108
namespace Ui {
class MainWindow;