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
+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();