Switched to newest version of qcustomplot.

This commit is contained in:
Collin Kidder
2017-08-06 21:25:17 -04:00
parent 470b8d3b0c
commit 83399ed0a7
7 changed files with 15564 additions and 6483 deletions
+14 -11
View File
@@ -196,6 +196,9 @@ bool FrameFileIO::loadVehicleSpyFile(QString filename, QVector<CANFrame> *frames
bool pastHeader = false;
bool foundErrors = false;
QDateTime now = QDateTime::currentDateTime();
QDateTime tempTime;
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
{
delete inFile;
@@ -224,7 +227,9 @@ bool FrameFileIO::loadVehicleSpyFile(QString filename, QVector<CANFrame> *frames
if (tokens.length() > 20)
{
thisFrame.bus = 0;
thisFrame.timestamp = tokens[1].toDouble() * 1000000.0;
tempTime = now;
tempTime.addMSecs(tokens[1].toDouble() * 1000.0);
thisFrame.timestamp = tempTime.toMSecsSinceEpoch() * 1000ul;
if (tokens[5].startsWith("T")) thisFrame.isReceived = false;
else thisFrame.isReceived = true;
thisFrame.ID = tokens[9].toInt(NULL, 16);
@@ -260,6 +265,7 @@ bool FrameFileIO::saveVehicleSpyFile(QString filename, const QVector<CANFrame> *
//CRTD format from Mark Webb-Johnson / OVMS project
/*
Sample data in CRTD format
Timestamp appears to be seconds since the epoch
1320745424.000 CXX OVMS Tesla Roadster cando2crtd converted log
1320745424.000 CXX OVMS Tesla roadster log: charge.20111108.csv
1320745424.002 R11 402 FA 01 C3 A0 96 00 07 01
@@ -503,7 +509,7 @@ bool FrameFileIO::loadNativeCSVFile(QString filename, QVector<CANFrame>* frames)
{
if (tokens[0].length() > 3)
{
long long temp = tokens[0].right(10).toLongLong();
long long temp = tokens[0].toLongLong();
thisFrame.timestamp = temp;
}
else
@@ -635,7 +641,7 @@ bool FrameFileIO::loadGenericCSVFile(QString filename, QVector<CANFrame>* frames
{
QList<QByteArray> tokens = line.split(',');
timeStamp += 5;
timeStamp += 5000;
thisFrame.timestamp = timeStamp;
thisFrame.ID = tokens[0].toInt(NULL, 16);
if (thisFrame.ID > 0x7FF) thisFrame.extended = true;
@@ -776,7 +782,7 @@ bool FrameFileIO::loadLogFile(QString filename, QVector<CANFrame>* frames)
frames->append(thisFrame);
}
else foundErrors = true;
}
}
}
inFile->close();
delete inFile;
@@ -789,7 +795,7 @@ bool FrameFileIO::saveLogFile(QString filename, const QVector<CANFrame>* frames)
QDateTime timestamp, tempStamp;
int lineCounter = 0;
timestamp = QDateTime::currentDateTime();
//timestamp = QDateTime::currentDateTime();
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
{
@@ -822,7 +828,7 @@ bool FrameFileIO::saveLogFile(QString filename, const QVector<CANFrame>* frames)
lineCounter = 0;
}
tempStamp = timestamp.addMSecs(frames->at(c).timestamp / 1000);
tempStamp = QDateTime::fromMSecsSinceEpoch(frames->at(c).timestamp / 1000);
outFile->write(tempStamp.toString("h:m:s:z").toUtf8());
if (frames->at(c).isReceived) outFile->write(" Rx ");
else outFile->write(" Tx ");
@@ -951,10 +957,7 @@ bool FrameFileIO::saveIXXATFile(QString filename, const QVector<CANFrame>* frame
qApp->processEvents();
lineCounter = 0;
}
timestamp.setTime(QTime());
tempStamp = timestamp.addMSecs(frames->at(c).timestamp / 1000);
tempStamp = QDateTime::fromMSecsSinceEpoch(frames->at(c).timestamp / 1000);
outFile->write("\"" + tempStamp.toString("h:m:s.").toUtf8() + tempStamp.toString("z").rightJustified(3, '0').toUtf8() + "\"");
outFile->write(",\"" + QString::number(frames->at(c).ID, 16).toUpper().rightJustified(8, '0').toUtf8() + "\"");
@@ -1448,7 +1451,7 @@ bool FrameFileIO::loadCanDumpFile(QString filename, QVector<CANFrame>* frames)
thisFrame.timestamp = timeExp.cap(1).toDouble(&ret) * 1000000;
if(!ret) continue;
/* ID & value */
QRegExp IdValExp("^(\\S+)#(\\S+)\n$");
qDebug() << tokens[2];
+1 -1
View File
@@ -8,7 +8,7 @@
#include "utility.h"
/*
Compile for all platforms and create release (remember to include QScintilla libs) and make Win32 binary.
Compile for all platforms and create release and make Win32 binary.
Some notes on things I'd like to put into the program but haven't put on github (yet)
+11923 -5705
View File
File diff suppressed because it is too large Load Diff
+3572 -711
View File
File diff suppressed because it is too large Load Diff
+20 -14
View File
@@ -10,7 +10,7 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
QDialog(parent),
ui(new Ui::FlowViewWindow)
{
ui->setupUi(this);
ui->setupUi(this);
readSettings();
@@ -33,7 +33,7 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
ui->graphView->axisRect()->setupFullAxesBox();
QCPItemText *textLabel = new QCPItemText(ui->graphView);
ui->graphView->addItem(textLabel);
//ui->graphView->addItem(textLabel);
textLabel->setPositionAlignment(Qt::AlignTop|Qt::AlignHCenter);
textLabel->position->setType(QCPItemPosition::ptAxisRectRatio);
textLabel->position->setCoords(0.5, .5);
@@ -53,11 +53,14 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
ui->graphView->legend->setSelectableParts(QCPLegend::spItems); // legend box shall not be selectable, only legend items
//ui->graphView->xAxis->setAutoSubTicks(false);
//ui->graphView->xAxis->setAutoTicks(false);
ui->graphView->xAxis->setAutoTickStep(false);
ui->graphView->xAxis->setAutoSubTicks(false);
ui->graphView->xAxis->setNumberFormat("gb");
ui->graphView->xAxis->setTickStep(5.0);
ui->graphView->xAxis->setSubTickCount(0);
QCPAxisTicker *xTicker = new QCPAxisTicker();
xTicker->setTickCount(10);
ui->graphView->xAxis->setTicker(QSharedPointer<QCPAxisTicker>(xTicker));
//ui->graphView->xAxis->setAutoTickStep(false);
//ui->graphView->xAxis->setAutoSubTicks(false);
//ui->graphView->xAxis->setNumberFormat("gb");
//ui->graphView->xAxis->setTickStep(5.0);
//ui->graphView->xAxis->setSubTickCount(0);
connect(ui->btnBackOne, SIGNAL(clicked(bool)), this, SLOT(btnBackOneClick()));
connect(ui->btnPause, SIGNAL(clicked(bool)), this, SLOT(btnPauseClick()));
@@ -68,7 +71,7 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
connect(ui->spinPlayback, SIGNAL(valueChanged(int)), this, SLOT(changePlaybackSpeed(int)));
connect(ui->cbLoopPlayback, SIGNAL(clicked(bool)), this, SLOT(changeLooping(bool)));
connect(ui->listFrameID, SIGNAL(currentTextChanged(QString)), this, SLOT(changeID(QString)));
connect(playbackTimer, SIGNAL(timeout()), this, SLOT(timerTriggered()));
connect(playbackTimer, SIGNAL(timeout()), this, SLOT(timerTriggered()));
connect(ui->graphView, SIGNAL(plottableDoubleClick(QCPAbstractPlottable*,QMouseEvent*)), this, SLOT(plottableDoubleClick(QCPAbstractPlottable*,QMouseEvent*)));
connect(ui->txtTrigger0, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues()));
connect(ui->txtTrigger1, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues()));
@@ -294,7 +297,7 @@ void FlowViewWindow::saveFileGraph()
if (dialog.selectedNameFilter() == filters[0])
{
if (!filename.contains('.')) filename += ".pdf";
ui->graphView->savePdf(filename, true, 0, 0);
ui->graphView->savePdf(filename, 0, 0);
}
if (dialog.selectedNameFilter() == filters[1])
{
@@ -408,7 +411,7 @@ void FlowViewWindow::updatedFrames(int numFrames)
y[k].append(thisFrame.data[k]);
needRefresh = true;
}
}
}
}
if (ui->cbLiveMode->checkState() == Qt::Checked)
{
@@ -689,7 +692,7 @@ void FlowViewWindow::updatePosition(bool forward)
memcpy(refBytes, currBytes, 8);
}
memcpy(currBytes, frameCache.at(currentPosition).data, 8);
memcpy(currBytes, frameCache.at(currentPosition).data, 8);
if (ui->cbSync->checkState() == Qt::Checked) emit sendCenterTimeID(frameCache[currentPosition].ID, frameCache[currentPosition].timestamp / 1000000.0);
}
@@ -705,26 +708,29 @@ void FlowViewWindow::updateGraphLocation()
{
if (secondsMode)
{
/*
ui->graphView->xAxis->setRange(frameCache[start].timestamp / 1000000.0, frameCache[end].timestamp / 1000000.0);
ui->graphView->xAxis->setTickStep((frameCache[end].timestamp - frameCache[start].timestamp)/ 3000000.0);
ui->graphView->xAxis->setSubTickCount(0);
ui->graphView->xAxis->setNumberFormat("f");
ui->graphView->xAxis->setNumberPrecision(6);
*/
}
else
{
/*
ui->graphView->xAxis->setRange(frameCache[start].timestamp, frameCache[end].timestamp);
ui->graphView->xAxis->setTickStep((frameCache[end].timestamp - frameCache[start].timestamp)/ 3.0);
ui->graphView->xAxis->setSubTickCount(0);
ui->graphView->xAxis->setNumberFormat("f");
ui->graphView->xAxis->setNumberPrecision(0);
ui->graphView->xAxis->setNumberPrecision(0); */
}
}
else
{
ui->graphView->xAxis->setRange(start, end);
ui->graphView->xAxis->setTickStep(5.0);
ui->graphView->xAxis->setSubTickCount(0);
//ui->graphView->xAxis->setTickStep(5.0);
//ui->graphView->xAxis->setSubTickCount(0);
ui->graphView->xAxis->setNumberFormat("gb");
}
+32 -39
View File
@@ -45,14 +45,14 @@ GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent)
connect(ui->graphingView, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged()));
//connect up the mouse controls
connect(ui->graphingView, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
connect(ui->graphingView, SIGNAL(plottableDoubleClick(QCPAbstractPlottable*,QMouseEvent*)), this, SLOT(plottableDoubleClick(QCPAbstractPlottable*,QMouseEvent*)));
connect(ui->graphingView, SIGNAL(plottableDoubleClick(QCPAbstractPlottable*,int,QMouseEvent*)), this, SLOT(plottableDoubleClick(QCPAbstractPlottable*,int,QMouseEvent*)));
connect(ui->graphingView, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));
// make bottom and left axes transfer their ranges to top and right axes:
connect(ui->graphingView->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->graphingView->xAxis2, SLOT(setRange(QCPRange)));
connect(ui->graphingView->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->graphingView->yAxis2, SLOT(setRange(QCPRange)));
connect(ui->graphingView, SIGNAL(titleDoubleClick(QMouseEvent*,QCPPlotTitle*)), this, SLOT(titleDoubleClick(QMouseEvent*,QCPPlotTitle*)));
//connect(ui->graphingView, SIGNAL(titleDoubleClick(QMouseEvent*,QCPTextElement*)), this, SLOT(titleDoubleClick(QMouseEvent*,QCPTextElement*)));
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*)));
@@ -67,6 +67,8 @@ GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent)
ui->graphingView->setAttribute(Qt::WA_AcceptTouchEvents);
ui->graphingView->setOpenGl(true); //purdy and fast drawing courtesy of your video card - pretty everyone has 3D accel these days
needScaleSetup = true;
}
@@ -166,8 +168,9 @@ void GraphingWindow::updatedFrames(int numFrames)
}
}
void GraphingWindow::plottableDoubleClick(QCPAbstractPlottable* plottable, QMouseEvent* event)
void GraphingWindow::plottableDoubleClick(QCPAbstractPlottable* plottable, int dataIdx, QMouseEvent* event)
{
Q_UNUSED(dataIdx);
int id = 0;
//apply transforms to get the X axis value where we double clicked
double coord = plottable->keyAxis()->pixelToCoord(event->localPos().x());
@@ -193,20 +196,22 @@ void GraphingWindow::gotCenterTimeID(int32_t ID, double timestamp)
ui->graphingView->replot();
}
void GraphingWindow::titleDoubleClick(QMouseEvent* event, QCPPlotTitle* title)
void GraphingWindow::titleDoubleClick(QMouseEvent* event, QCPTextElement* title)
{
Q_UNUSED(event)
Q_UNUSED(title)
qDebug() << "title Double Click";
// Set the plot title by double clicking on it
/*
/*
bool ok;
QString newTitle = QInputDialog::getText(this, "SavvyCAN Graphing", "New plot title:", QLineEdit::Normal, title->text(), &ok);
if (ok)
{
title->setText(newTitle);
ui->graphingView->replot();
}
*/
} */
editSelectedGraph();
}
@@ -227,33 +232,21 @@ void GraphingWindow::axisLabelDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart
void GraphingWindow::legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item)
{
// Rename a graph by double clicking on its legend item
Q_UNUSED(legend)
if (item) // only react if item was clicked (user could have clicked on border padding of legend where there is no item, then item is 0)
{/*
QCPPlottableLegendItem *plItem = qobject_cast<QCPPlottableLegendItem*>(item);
bool ok;
QString newName = QInputDialog::getText(this, "SavvyCAN Graphing", "New graph name:", QLineEdit::Normal, plItem->plottable()->name(), &ok);
if (ok)
{
plItem->plottable()->setName(newName);
if (ui->graphingView->selectedGraphs().size() > 0)
{
for (int i = 0; i < graphParams.count(); i++)
{
if (graphParams[i].ref == ui->graphingView->selectedGraphs().first())
{
graphParams[i].graphName = newName;
break;
}
}
}
ui->graphingView->replot();
} */
editSelectedGraph();
}
// Rename a graph by double clicking on its legend item
qDebug() << "Legend Double Click " << item;
Q_UNUSED(legend)
if (item) // only react if item was clicked (user could have clicked on border padding of legend where there is no item, then item is 0)
{
QCPPlottableLegendItem *plItem = qobject_cast<QCPPlottableLegendItem*>(item);
QCPGraph *pGraph = qobject_cast<QCPGraph *>(plItem->plottable());
QCPDataSelection sel;
QCPDataRange rang;
rang.setBegin(0);
rang.setEnd(pGraph->dataCount());
sel.addDataRange(rang);
pGraph->setSelection(sel);
editSelectedGraph();
}
}
void GraphingWindow::selectionChanged()
@@ -294,7 +287,7 @@ void GraphingWindow::selectionChanged()
if (item->selected() || graph->selected())
{
item->setSelected(true);
graph->setSelected(true);
//graph->setSelected(true);
}
}
}
@@ -543,7 +536,7 @@ void GraphingWindow::saveGraphs()
if (dialog.selectedNameFilter() == filters[0])
{
if (!filename.contains('.')) filename += ".pdf";
ui->graphingView->savePdf(filename, true, 0, 0);
ui->graphingView->savePdf(filename, 0, 0);
}
if (dialog.selectedNameFilter() == filters[1])
{
@@ -1009,14 +1002,14 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
params.xbias = 0;
ui->graphingView->addGraph();
params.ref = ui->graphingView->graph();
params.ref = ui->graphingView->graph();
if (createGraphParam)
{
graphParams.append(params);
refParam = &graphParams.last();
}
ui->graphingView->graph()->setSelectedBrush(Qt::NoBrush);
ui->graphingView->graph()->setSelectedPen(selectedPen);
//ui->graphingView->graph()->setSelectedBrush(Qt::NoBrush);
//ui->graphingView->graph()->setSelectedPen(selectedPen);
if (params.graphName == NULL || params.graphName.length() == 0)
{
+2 -2
View File
@@ -40,10 +40,10 @@ public:
void showEvent(QShowEvent*);
private slots:
void titleDoubleClick(QMouseEvent *event, QCPPlotTitle *title);
void titleDoubleClick(QMouseEvent *event, QCPTextElement *title);
void axisLabelDoubleClick(QCPAxis* axis, QCPAxis::SelectablePart part);
void legendDoubleClick(QCPLegend* legend, QCPAbstractLegendItem* item);
void plottableDoubleClick(QCPAbstractPlottable* plottable,QMouseEvent* event);
void plottableDoubleClick(QCPAbstractPlottable* plottable,int dataIdx, QMouseEvent* event);
void selectionChanged();
void mousePress();
void mouseWheel();