GraphWindow: support double-clicking the axis to resize it to the data
This commit is contained in:
@@ -68,7 +68,7 @@ GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent)
|
|||||||
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*,QCPTextElement*)), this, SLOT(titleDoubleClick(QMouseEvent*,QCPTextElement*)));
|
//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(axisDoubleClick(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(ui->graphingView, SIGNAL(legendClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this, SLOT(legendSingleClick(QCPLegend*,QCPAbstractLegendItem*)));
|
connect(ui->graphingView, SIGNAL(legendClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this, SLOT(legendSingleClick(QCPLegend*,QCPAbstractLegendItem*)));
|
||||||
|
|
||||||
@@ -294,11 +294,10 @@ void GraphingWindow::titleDoubleClick(QMouseEvent* event, QCPTextElement* title)
|
|||||||
editSelectedGraph();
|
editSelectedGraph();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphingWindow::axisLabelDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part)
|
void GraphingWindow::axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part)
|
||||||
{
|
{
|
||||||
qDebug() << "axisLabelDoubleClick";
|
qDebug() << "axisDoubleClick";
|
||||||
// Set an axis label by double clicking on it
|
if (part == QCPAxis::spAxisLabel) // Set an axis label by double clicking on it
|
||||||
if (part == QCPAxis::spAxisLabel) // only react when the actual axis label is clicked, not tick label or axis backbone
|
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
QString newLabel = QInputDialog::getText(this, "SavvyCAN Graphing", "New axis label:", QLineEdit::Normal, axis->label(), &ok);
|
QString newLabel = QInputDialog::getText(this, "SavvyCAN Graphing", "New axis label:", QLineEdit::Normal, axis->label(), &ok);
|
||||||
@@ -307,6 +306,10 @@ void GraphingWindow::axisLabelDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart
|
|||||||
axis->setLabel(newLabel);
|
axis->setLabel(newLabel);
|
||||||
ui->graphingView->replot();
|
ui->graphingView->replot();
|
||||||
}
|
}
|
||||||
|
} else if (part == QCPAxis::spAxis) // Resize an axis to fit by double clicking it
|
||||||
|
{
|
||||||
|
axis->rescale(true);
|
||||||
|
ui->graphingView->replot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void titleDoubleClick(QMouseEvent *event, QCPTextElement *title);
|
void titleDoubleClick(QMouseEvent *event, QCPTextElement *title);
|
||||||
void axisLabelDoubleClick(QCPAxis* axis, QCPAxis::SelectablePart part);
|
void axisDoubleClick(QCPAxis* axis, QCPAxis::SelectablePart part);
|
||||||
void legendDoubleClick(QCPLegend* legend, QCPAbstractLegendItem* item);
|
void legendDoubleClick(QCPLegend* legend, QCPAbstractLegendItem* item);
|
||||||
void legendSingleClick(QCPLegend* legend, QCPAbstractLegendItem* item);
|
void legendSingleClick(QCPLegend* legend, QCPAbstractLegendItem* item);
|
||||||
void plottableDoubleClick(QCPAbstractPlottable* plottable,int dataIdx, QMouseEvent* event);
|
void plottableDoubleClick(QCPAbstractPlottable* plottable,int dataIdx, QMouseEvent* event);
|
||||||
|
|||||||
Reference in New Issue
Block a user