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 "graphingwindow.h"
|
||||||
#include "ui_graphingwindow.h"
|
#include "ui_graphingwindow.h"
|
||||||
#include "newgraphdialog.h"
|
#include "newgraphdialog.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
GraphingWindow::GraphingWindow(QVector<CANFrame> *frames, QWidget *parent) :
|
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(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(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:
|
// setup policy and connect slot for context menu popup:
|
||||||
ui->graphingView->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->graphingView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(ui->graphingView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));
|
connect(ui->graphingView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));
|
||||||
@@ -63,8 +66,33 @@ GraphingWindow::~GraphingWindow()
|
|||||||
void GraphingWindow::showEvent(QShowEvent* event)
|
void GraphingWindow::showEvent(QShowEvent* event)
|
||||||
{
|
{
|
||||||
QDialog::showEvent(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)
|
void GraphingWindow::titleDoubleClick(QMouseEvent* event, QCPPlotTitle* title)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
@@ -279,7 +307,7 @@ void GraphingWindow::addNewGraph()
|
|||||||
showParamsDialog(-1);
|
showParamsDialog(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphingWindow::createGraph(GraphParams ¶ms)
|
void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
||||||
{
|
{
|
||||||
int tempVal;
|
int tempVal;
|
||||||
float minval=1000000, maxval = -100000;
|
float minval=1000000, maxval = -100000;
|
||||||
@@ -376,7 +404,7 @@ void GraphingWindow::createGraph(GraphParams ¶ms)
|
|||||||
}
|
}
|
||||||
ui->graphingView->addGraph();
|
ui->graphingView->addGraph();
|
||||||
params.ref = ui->graphingView->graph();
|
params.ref = ui->graphingView->graph();
|
||||||
graphParams.append(params);
|
if (createGraphParam) graphParams.append(params);
|
||||||
ui->graphingView->graph()->setSelectedBrush(Qt::NoBrush);
|
ui->graphingView->graph()->setSelectedBrush(Qt::NoBrush);
|
||||||
ui->graphingView->graph()->setSelectedPen(selectedPen);
|
ui->graphingView->graph()->setSelectedPen(selectedPen);
|
||||||
ui->graphingView->graph()->setName(QString("Graph %1").arg(ui->graphingView->graphCount()-1));
|
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 contextMenuRequest(QPoint pos);
|
||||||
void moveLegend();
|
void moveLegend();
|
||||||
void addNewGraph();
|
void addNewGraph();
|
||||||
void createGraph(GraphParams ¶ms);
|
void createGraph(GraphParams ¶ms, bool createGraphParam = true);
|
||||||
void editSelectedGraph();
|
void editSelectedGraph();
|
||||||
|
void updatedFrames(int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::GraphingWindow *ui;
|
Ui::GraphingWindow *ui;
|
||||||
|
|||||||
+5
-2
@@ -557,8 +557,8 @@ void MainWindow::loadLogFile(QString filename)
|
|||||||
{
|
{
|
||||||
QList<QByteArray> tokens = line.split(' ');
|
QList<QByteArray> tokens = line.split(' ');
|
||||||
QList<QByteArray> timeToks = tokens[0].split(':');
|
QList<QByteArray> timeToks = tokens[0].split(':');
|
||||||
timeStamp = (timeToks[0].toInt() * (1000 * 1000 * 60 * 60)) + (timeToks[1].toInt() * (1000 * 1000 * 60))
|
timeStamp = (timeToks[0].toInt() * (1000ul * 1000ul * 60ul * 60ul)) + (timeToks[1].toInt() * (1000ul * 1000ul * 60ul))
|
||||||
+ (timeToks[2].toInt() * (1000 * 1000)) + (timeToks[3].toInt() * 100);
|
+ (timeToks[2].toInt() * (1000ul * 1000ul)) + (timeToks[3].toInt() * 100ul);
|
||||||
thisFrame.timestamp = timeStamp;
|
thisFrame.timestamp = timeStamp;
|
||||||
thisFrame.ID = tokens[3].right(tokens[3].length() - 2).toInt(NULL, 16);
|
thisFrame.ID = tokens[3].right(tokens[3].length() - 2).toInt(NULL, 16);
|
||||||
if (tokens[4] == "s") thisFrame.extended = false;
|
if (tokens[4] == "s") thisFrame.extended = false;
|
||||||
@@ -670,6 +670,9 @@ void MainWindow::handleLoadFile()
|
|||||||
filename = dialog.selectedFiles()[0];
|
filename = dialog.selectedFiles()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->canFramesView->scrollToTop();
|
||||||
|
model->clearFrames();
|
||||||
|
|
||||||
if (dialog.selectedNameFilter() == filters[0]) loadCRTDFile(filename);
|
if (dialog.selectedNameFilter() == filters[0]) loadCRTDFile(filename);
|
||||||
if (dialog.selectedNameFilter() == filters[1]) loadNativeCSVFile(filename);
|
if (dialog.selectedNameFilter() == filters[1]) loadNativeCSVFile(filename);
|
||||||
if (dialog.selectedNameFilter() == filters[2]) loadGenericCSVFile(filename);
|
if (dialog.selectedNameFilter() == filters[2]) loadGenericCSVFile(filename);
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
#include "dbchandler.h"
|
#include "dbchandler.h"
|
||||||
#include "dbcmaineditor.h"
|
#include "dbcmaineditor.h"
|
||||||
|
|
||||||
#define VERSION 107
|
#define VERSION 108
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
|||||||
Reference in New Issue
Block a user