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:
+30
-2
@@ -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 ¶ms)
|
||||
void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
||||
{
|
||||
int tempVal;
|
||||
float minval=1000000, maxval = -100000;
|
||||
@@ -376,7 +404,7 @@ void GraphingWindow::createGraph(GraphParams ¶ms)
|
||||
}
|
||||
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
@@ -45,8 +45,9 @@ private slots:
|
||||
void contextMenuRequest(QPoint pos);
|
||||
void moveLegend();
|
||||
void addNewGraph();
|
||||
void createGraph(GraphParams ¶ms);
|
||||
void createGraph(GraphParams ¶ms, bool createGraphParam = true);
|
||||
void editSelectedGraph();
|
||||
void updatedFrames(int);
|
||||
|
||||
private:
|
||||
Ui::GraphingWindow *ui;
|
||||
|
||||
+5
-2
@@ -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
@@ -14,7 +14,7 @@
|
||||
#include "dbchandler.h"
|
||||
#include "dbcmaineditor.h"
|
||||
|
||||
#define VERSION 107
|
||||
#define VERSION 108
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
|
||||
Reference in New Issue
Block a user