From a341c7f4f29904260505ce1030f1804fb15ac13c Mon Sep 17 00:00:00 2001 From: Grieb Date: Tue, 14 Apr 2015 15:52:45 -0300 Subject: [PATCH] [companion][logsDialog]Two recomendations from QCustomPlot for performance. --- companion/src/logsdialog.cpp | 51 +++--------------------------------- 1 file changed, 3 insertions(+), 48 deletions(-) diff --git a/companion/src/logsdialog.cpp b/companion/src/logsdialog.cpp index beaecb70e..e5d2646f3 100644 --- a/companion/src/logsdialog.cpp +++ b/companion/src/logsdialog.cpp @@ -12,7 +12,6 @@ logsDialog::logsDialog(QWidget *parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), ui(new Ui::logsDialog) { - qDebug() << "logsDialog"; csvlog.clear(); ui->setupUi(this); @@ -32,7 +31,7 @@ logsDialog::logsDialog(QWidget *parent) : colors.append(Qt::darkMagenta); colors.append(Qt::darkCyan); colors.append(Qt::blue); - pen.setWidthF(1.5); + pen.setWidthF(1.0); // create and prepare a plot title layout element QCPPlotTitle *title = new QCPPlotTitle(ui->customPlot); @@ -42,6 +41,8 @@ logsDialog::logsDialog(QWidget *parent) : ui->customPlot->plotLayout()->insertRow(0); ui->customPlot->plotLayout()->addElement(0, 0, title); + ui->customPlot->setNoAntialiasingOnDrag(true); + ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables); @@ -85,13 +86,11 @@ logsDialog::logsDialog(QWidget *parent) : logsDialog::~logsDialog() { - qDebug() << "~logsDialog"; delete ui; } void logsDialog::titleDoubleClick(QMouseEvent *evt, QCPPlotTitle *title) { - qDebug() << "titleDoubleClick"; // Set the plot title by double clicking on it bool ok; @@ -106,7 +105,6 @@ void logsDialog::titleDoubleClick(QMouseEvent *evt, QCPPlotTitle *title) void logsDialog::axisLabelDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part) { - qDebug() << "axisLabelDoubleClick"; // 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 { @@ -122,7 +120,6 @@ void logsDialog::axisLabelDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart par void logsDialog::legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item) { - qDebug() << "legendDoubleClick"; // Rename a graph by double clicking on its legend item 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) { @@ -144,7 +141,6 @@ void logsDialog::legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *ite void logsDialog::selectionChanged() { - qDebug() << "selectionChanged"; /* normally, axis base line, axis tick labels and axis labels are selectable separately, but we want the user only to be able to select the axis as a whole, so we tie the selected states of the tick labels @@ -197,8 +193,6 @@ void logsDialog::selectionChanged() void logsDialog::on_mapsButton_clicked() { - qDebug() << "on_mapsButton_clicked"; - int n = csvlog.count(); // number of points in graph if (n==0) return; int latcol=0, longcol=0, altcol=0, speedcol=0; @@ -366,8 +360,6 @@ void logsDialog::on_mapsButton_clicked() void logsDialog::mousePress() { - qDebug() << "mousePress"; - // if an axis is selected, only allow the direction of that axis to be dragged // if no axis is selected, both directions may be dragged @@ -381,7 +373,6 @@ void logsDialog::mousePress() void logsDialog::mouseWheel() { - qDebug() << "mouseWheel"; // if an axis is selected, only allow the direction of that axis to be zoomed // if no axis is selected, both directions may be zoomed int orientation=0; @@ -400,8 +391,6 @@ void logsDialog::mouseWheel() void logsDialog::removeSelectedGraph() { - qDebug() << "removeSelectedGraph"; - if (ui->customPlot->selectedGraphs().size() > 0) { ui->customPlot->removeGraph(ui->customPlot->selectedGraphs().first()); @@ -411,8 +400,6 @@ void logsDialog::removeSelectedGraph() void logsDialog::removeAllGraphs() { - qDebug() << "removeAllGraphs"; - ui->customPlot->clearGraphs(); ui->customPlot->legend->setVisible(false); ui->customPlot->yAxis2->setVisible(false); @@ -436,14 +423,9 @@ void logsDialog::removeAllGraphs() void logsDialog::on_fileOpen_BT_clicked() { - qDebug() << "on_fileOpen_BT_clicked"; - QString fileName = QFileDialog::getOpenFileName(this,tr("Select your log file"), g.logDir()); if (!fileName.isEmpty()) { - QElapsedTimer timer; - timer.start(); - g.logDir( fileName ); ui->FileName_LE->setText(fileName); if (cvsFileParse()) { @@ -484,26 +466,12 @@ void logsDialog::on_fileOpen_BT_clicked() for (int i = 0; i < ui->logTable->columnCount(); i++) { ui->logTable->setColumnWidth(i, sizes.at(i)); } - // ui->logTable->resizeColumnsToContents(); - // ui->logTable->resizeRowsToContents(); - // Hack - add some pixel of space to columns as Qt resize them too small - // for (int j=0; jlogTable->columnWidth(j); - // ui->logTable->setColumnWidth(j,width+5); - // } } - - qDebug() << timer.elapsed(); } } bool logsDialog::cvsFileParse() { - qDebug() << "cvsFileParse"; - - QElapsedTimer timer; - timer.start(); - QFile file(ui->FileName_LE->text()); int errors=0; int lines=-1; @@ -600,16 +568,12 @@ bool logsDialog::cvsFileParse() plotLock=false; - qDebug() << timer.elapsed(); - return true; } void logsDialog::on_sessions_CB_currentIndexChanged(int index) { - qDebug() << "on_sessions_CB_currentIndexChanged"; - if (plotLock) return; plotLock = true; @@ -638,8 +602,6 @@ void logsDialog::on_sessions_CB_currentIndexChanged(int index) void logsDialog::plotLogs() { - qDebug() << "plotLogs"; - if (plotLock) return; if (!ui->FieldsTW->selectedItems().length()) { @@ -647,9 +609,6 @@ void logsDialog::plotLogs() return; } - QElapsedTimer timer; - timer.start(); - plotsCollection plots; QModelIndexList selection = ui->logTable->selectionModel()->selectedRows(); @@ -829,14 +788,10 @@ void logsDialog::plotLogs() ui->customPlot->legend->setVisible(true); ui->customPlot->replot(); - - qDebug() << timer.elapsed(); } void logsDialog::setRangeyAxis2(QCPRange range) { - qDebug() << "setRangeyAxis2"; - if (hasyAxis2) { double lowerChange = (range.lower - rangeyAxisMin) * rangeRatio; double upperChange = (range.upper - rangeyAxisMax) * rangeRatio;