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
+12 -9
View File
@@ -196,6 +196,9 @@ bool FrameFileIO::loadVehicleSpyFile(QString filename, QVector<CANFrame> *frames
bool pastHeader = false; bool pastHeader = false;
bool foundErrors = false; bool foundErrors = false;
QDateTime now = QDateTime::currentDateTime();
QDateTime tempTime;
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text)) if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
{ {
delete inFile; delete inFile;
@@ -224,7 +227,9 @@ bool FrameFileIO::loadVehicleSpyFile(QString filename, QVector<CANFrame> *frames
if (tokens.length() > 20) if (tokens.length() > 20)
{ {
thisFrame.bus = 0; 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; if (tokens[5].startsWith("T")) thisFrame.isReceived = false;
else thisFrame.isReceived = true; else thisFrame.isReceived = true;
thisFrame.ID = tokens[9].toInt(NULL, 16); 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 //CRTD format from Mark Webb-Johnson / OVMS project
/* /*
Sample data in CRTD format 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 cando2crtd converted log
1320745424.000 CXX OVMS Tesla roadster log: charge.20111108.csv 1320745424.000 CXX OVMS Tesla roadster log: charge.20111108.csv
1320745424.002 R11 402 FA 01 C3 A0 96 00 07 01 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) if (tokens[0].length() > 3)
{ {
long long temp = tokens[0].right(10).toLongLong(); long long temp = tokens[0].toLongLong();
thisFrame.timestamp = temp; thisFrame.timestamp = temp;
} }
else else
@@ -635,7 +641,7 @@ bool FrameFileIO::loadGenericCSVFile(QString filename, QVector<CANFrame>* frames
{ {
QList<QByteArray> tokens = line.split(','); QList<QByteArray> tokens = line.split(',');
timeStamp += 5; timeStamp += 5000;
thisFrame.timestamp = timeStamp; thisFrame.timestamp = timeStamp;
thisFrame.ID = tokens[0].toInt(NULL, 16); thisFrame.ID = tokens[0].toInt(NULL, 16);
if (thisFrame.ID > 0x7FF) thisFrame.extended = true; if (thisFrame.ID > 0x7FF) thisFrame.extended = true;
@@ -789,7 +795,7 @@ bool FrameFileIO::saveLogFile(QString filename, const QVector<CANFrame>* frames)
QDateTime timestamp, tempStamp; QDateTime timestamp, tempStamp;
int lineCounter = 0; int lineCounter = 0;
timestamp = QDateTime::currentDateTime(); //timestamp = QDateTime::currentDateTime();
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text)) if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
{ {
@@ -822,7 +828,7 @@ bool FrameFileIO::saveLogFile(QString filename, const QVector<CANFrame>* frames)
lineCounter = 0; 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()); outFile->write(tempStamp.toString("h:m:s:z").toUtf8());
if (frames->at(c).isReceived) outFile->write(" Rx "); if (frames->at(c).isReceived) outFile->write(" Rx ");
else outFile->write(" Tx "); else outFile->write(" Tx ");
@@ -951,10 +957,7 @@ bool FrameFileIO::saveIXXATFile(QString filename, const QVector<CANFrame>* frame
qApp->processEvents(); qApp->processEvents();
lineCounter = 0; lineCounter = 0;
} }
tempStamp = QDateTime::fromMSecsSinceEpoch(frames->at(c).timestamp / 1000);
timestamp.setTime(QTime());
tempStamp = timestamp.addMSecs(frames->at(c).timestamp / 1000);
outFile->write("\"" + tempStamp.toString("h:m:s.").toUtf8() + tempStamp.toString("z").rightJustified(3, '0').toUtf8() + "\""); 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() + "\""); outFile->write(",\"" + QString::number(frames->at(c).ID, 16).toUpper().rightJustified(8, '0').toUtf8() + "\"");
+1 -1
View File
@@ -8,7 +8,7 @@
#include "utility.h" #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) Some notes on things I'd like to put into the program but haven't put on github (yet)
+11766 -5548
View File
File diff suppressed because it is too large Load Diff
+3557 -696
View File
File diff suppressed because it is too large Load Diff
+16 -10
View File
@@ -33,7 +33,7 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
ui->graphView->axisRect()->setupFullAxesBox(); ui->graphView->axisRect()->setupFullAxesBox();
QCPItemText *textLabel = new QCPItemText(ui->graphView); QCPItemText *textLabel = new QCPItemText(ui->graphView);
ui->graphView->addItem(textLabel); //ui->graphView->addItem(textLabel);
textLabel->setPositionAlignment(Qt::AlignTop|Qt::AlignHCenter); textLabel->setPositionAlignment(Qt::AlignTop|Qt::AlignHCenter);
textLabel->position->setType(QCPItemPosition::ptAxisRectRatio); textLabel->position->setType(QCPItemPosition::ptAxisRectRatio);
textLabel->position->setCoords(0.5, .5); 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->legend->setSelectableParts(QCPLegend::spItems); // legend box shall not be selectable, only legend items
//ui->graphView->xAxis->setAutoSubTicks(false); //ui->graphView->xAxis->setAutoSubTicks(false);
//ui->graphView->xAxis->setAutoTicks(false); //ui->graphView->xAxis->setAutoTicks(false);
ui->graphView->xAxis->setAutoTickStep(false); QCPAxisTicker *xTicker = new QCPAxisTicker();
ui->graphView->xAxis->setAutoSubTicks(false); xTicker->setTickCount(10);
ui->graphView->xAxis->setNumberFormat("gb"); ui->graphView->xAxis->setTicker(QSharedPointer<QCPAxisTicker>(xTicker));
ui->graphView->xAxis->setTickStep(5.0); //ui->graphView->xAxis->setAutoTickStep(false);
ui->graphView->xAxis->setSubTickCount(0); //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->btnBackOne, SIGNAL(clicked(bool)), this, SLOT(btnBackOneClick()));
connect(ui->btnPause, SIGNAL(clicked(bool)), this, SLOT(btnPauseClick())); connect(ui->btnPause, SIGNAL(clicked(bool)), this, SLOT(btnPauseClick()));
@@ -294,7 +297,7 @@ void FlowViewWindow::saveFileGraph()
if (dialog.selectedNameFilter() == filters[0]) if (dialog.selectedNameFilter() == filters[0])
{ {
if (!filename.contains('.')) filename += ".pdf"; if (!filename.contains('.')) filename += ".pdf";
ui->graphView->savePdf(filename, true, 0, 0); ui->graphView->savePdf(filename, 0, 0);
} }
if (dialog.selectedNameFilter() == filters[1]) if (dialog.selectedNameFilter() == filters[1])
{ {
@@ -705,26 +708,29 @@ void FlowViewWindow::updateGraphLocation()
{ {
if (secondsMode) if (secondsMode)
{ {
/*
ui->graphView->xAxis->setRange(frameCache[start].timestamp / 1000000.0, frameCache[end].timestamp / 1000000.0); 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->setTickStep((frameCache[end].timestamp - frameCache[start].timestamp)/ 3000000.0);
ui->graphView->xAxis->setSubTickCount(0); ui->graphView->xAxis->setSubTickCount(0);
ui->graphView->xAxis->setNumberFormat("f"); ui->graphView->xAxis->setNumberFormat("f");
ui->graphView->xAxis->setNumberPrecision(6); ui->graphView->xAxis->setNumberPrecision(6);
*/
} }
else else
{ {
/*
ui->graphView->xAxis->setRange(frameCache[start].timestamp, frameCache[end].timestamp); 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->setTickStep((frameCache[end].timestamp - frameCache[start].timestamp)/ 3.0);
ui->graphView->xAxis->setSubTickCount(0); ui->graphView->xAxis->setSubTickCount(0);
ui->graphView->xAxis->setNumberFormat("f"); ui->graphView->xAxis->setNumberFormat("f");
ui->graphView->xAxis->setNumberPrecision(0); ui->graphView->xAxis->setNumberPrecision(0); */
} }
} }
else else
{ {
ui->graphView->xAxis->setRange(start, end); ui->graphView->xAxis->setRange(start, end);
ui->graphView->xAxis->setTickStep(5.0); //ui->graphView->xAxis->setTickStep(5.0);
ui->graphView->xAxis->setSubTickCount(0); //ui->graphView->xAxis->setSubTickCount(0);
ui->graphView->xAxis->setNumberFormat("gb"); ui->graphView->xAxis->setNumberFormat("gb");
} }
+24 -31
View File
@@ -45,14 +45,14 @@ GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent)
connect(ui->graphingView, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged())); connect(ui->graphingView, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged()));
//connect up the mouse controls //connect up the mouse controls
connect(ui->graphingView, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress())); 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())); connect(ui->graphingView, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));
// make bottom and left axes transfer their ranges to top and right axes: // 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->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->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(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*)));
@@ -67,6 +67,8 @@ GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent)
ui->graphingView->setAttribute(Qt::WA_AcceptTouchEvents); 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; 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; int id = 0;
//apply transforms to get the X axis value where we double clicked //apply transforms to get the X axis value where we double clicked
double coord = plottable->keyAxis()->pixelToCoord(event->localPos().x()); double coord = plottable->keyAxis()->pixelToCoord(event->localPos().x());
@@ -193,20 +196,22 @@ void GraphingWindow::gotCenterTimeID(int32_t ID, double timestamp)
ui->graphingView->replot(); ui->graphingView->replot();
} }
void GraphingWindow::titleDoubleClick(QMouseEvent* event, QCPPlotTitle* title) void GraphingWindow::titleDoubleClick(QMouseEvent* event, QCPTextElement* title)
{ {
Q_UNUSED(event) Q_UNUSED(event)
Q_UNUSED(title) Q_UNUSED(title)
qDebug() << "title Double Click";
// Set the plot title by double clicking on it // 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); QString newTitle = QInputDialog::getText(this, "SavvyCAN Graphing", "New plot title:", QLineEdit::Normal, title->text(), &ok);
if (ok) if (ok)
{ {
title->setText(newTitle); title->setText(newTitle);
ui->graphingView->replot(); ui->graphingView->replot();
} } */
*/
editSelectedGraph(); editSelectedGraph();
} }
@@ -228,30 +233,18 @@ void GraphingWindow::axisLabelDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart
void GraphingWindow::legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item) void GraphingWindow::legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item)
{ {
// Rename a graph by double clicking on its legend item // Rename a graph by double clicking on its legend item
qDebug() << "Legend Double Click " << item;
Q_UNUSED(legend) 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) 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); QCPPlottableLegendItem *plItem = qobject_cast<QCPPlottableLegendItem*>(item);
bool ok; QCPGraph *pGraph = qobject_cast<QCPGraph *>(plItem->plottable());
QString newName = QInputDialog::getText(this, "SavvyCAN Graphing", "New graph name:", QLineEdit::Normal, plItem->plottable()->name(), &ok); QCPDataSelection sel;
if (ok) QCPDataRange rang;
{ rang.setBegin(0);
plItem->plottable()->setName(newName); rang.setEnd(pGraph->dataCount());
sel.addDataRange(rang);
if (ui->graphingView->selectedGraphs().size() > 0) pGraph->setSelection(sel);
{
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(); editSelectedGraph();
} }
} }
@@ -294,7 +287,7 @@ void GraphingWindow::selectionChanged()
if (item->selected() || graph->selected()) if (item->selected() || graph->selected())
{ {
item->setSelected(true); item->setSelected(true);
graph->setSelected(true); //graph->setSelected(true);
} }
} }
} }
@@ -543,7 +536,7 @@ void GraphingWindow::saveGraphs()
if (dialog.selectedNameFilter() == filters[0]) if (dialog.selectedNameFilter() == filters[0])
{ {
if (!filename.contains('.')) filename += ".pdf"; if (!filename.contains('.')) filename += ".pdf";
ui->graphingView->savePdf(filename, true, 0, 0); ui->graphingView->savePdf(filename, 0, 0);
} }
if (dialog.selectedNameFilter() == filters[1]) if (dialog.selectedNameFilter() == filters[1])
{ {
@@ -1015,8 +1008,8 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
graphParams.append(params); graphParams.append(params);
refParam = &graphParams.last(); refParam = &graphParams.last();
} }
ui->graphingView->graph()->setSelectedBrush(Qt::NoBrush); //ui->graphingView->graph()->setSelectedBrush(Qt::NoBrush);
ui->graphingView->graph()->setSelectedPen(selectedPen); //ui->graphingView->graph()->setSelectedPen(selectedPen);
if (params.graphName == NULL || params.graphName.length() == 0) if (params.graphName == NULL || params.graphName.length() == 0)
{ {
+2 -2
View File
@@ -40,10 +40,10 @@ public:
void showEvent(QShowEvent*); void showEvent(QShowEvent*);
private slots: private slots:
void titleDoubleClick(QMouseEvent *event, QCPPlotTitle *title); void titleDoubleClick(QMouseEvent *event, QCPTextElement *title);
void axisLabelDoubleClick(QCPAxis* axis, QCPAxis::SelectablePart part); void axisLabelDoubleClick(QCPAxis* axis, QCPAxis::SelectablePart part);
void legendDoubleClick(QCPLegend* legend, QCPAbstractLegendItem* item); void legendDoubleClick(QCPLegend* legend, QCPAbstractLegendItem* item);
void plottableDoubleClick(QCPAbstractPlottable* plottable,QMouseEvent* event); void plottableDoubleClick(QCPAbstractPlottable* plottable,int dataIdx, QMouseEvent* event);
void selectionChanged(); void selectionChanged();
void mousePress(); void mousePress();
void mouseWheel(); void mouseWheel();