Fixes to Flowview and Graphing windows to make them work with new

QCustomPlot version
This commit is contained in:
Collin Kidder
2017-08-13 18:01:05 -04:00
parent c05bd2c043
commit 280a3e11d7
3 changed files with 29 additions and 5 deletions
+2 -2
View File
@@ -708,8 +708,8 @@ 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");
@@ -718,8 +718,8 @@ void FlowViewWindow::updateGraphLocation()
}
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");
+25 -3
View File
@@ -55,6 +55,7 @@ GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent)
//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*)));
connect(ui->graphingView, SIGNAL(legendClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this, SLOT(legendSingleClick(QCPLegend*,QCPAbstractLegendItem*)));
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
@@ -230,9 +231,27 @@ void GraphingWindow::axisLabelDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart
}
}
void GraphingWindow::legendSingleClick(QCPLegend *legend, QCPAbstractLegendItem *item)
{
// select a graph by clicking on the legend
qDebug() << "Legend Single 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);
}
}
void GraphingWindow::legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item)
{
// Rename a graph by double clicking on its legend item
// edit 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)
@@ -1008,8 +1027,11 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
graphParams.append(params);
refParam = &graphParams.last();
}
//ui->graphingView->graph()->setSelectedBrush(Qt::NoBrush);
//ui->graphingView->graph()->setSelectedPen(selectedPen);
selDecorator = new QCPSelectionDecorator(); //this has to be a pointer as it is freed internally to qcustomplot classes
selDecorator->setBrush(Qt::NoBrush);
selDecorator->setPen(selectedPen);
ui->graphingView->graph()->setSelectionDecorator(selDecorator);
if (params.graphName == NULL || params.graphName.length() == 0)
{
+2
View File
@@ -43,6 +43,7 @@ private slots:
void titleDoubleClick(QMouseEvent *event, QCPTextElement *title);
void axisLabelDoubleClick(QCPAxis* axis, QCPAxis::SelectablePart part);
void legendDoubleClick(QCPLegend* legend, QCPAbstractLegendItem* item);
void legendSingleClick(QCPLegend* legend, QCPAbstractLegendItem* item);
void plottableDoubleClick(QCPAbstractPlottable* plottable,int dataIdx, QMouseEvent* event);
void selectionChanged();
void mousePress();
@@ -75,6 +76,7 @@ private:
const QVector<CANFrame> *modelFrames;
QList<GraphParams> graphParams;
QPen selectedPen;
QCPSelectionDecorator *selDecorator;
bool needScaleSetup; //do we need to set x,y graphing extents?
bool secondsMode;