void AP2DataPlot2D::navModeChanged(int uasid, int mode, const QString& text) { Q_UNUSED(mode); if (m_uas->getUASID() != uasid) { return; } if (m_logLoaded) { //If a log is currently loaded, we don't care about incoming data. return; } qint64 msec_current = QDateTime::currentMSecsSinceEpoch(); m_currentIndex = msec_current; qint64 newmsec = (msec_current - m_startIndex) + m_timeDiff; if (m_graphCount > 0 && ui.autoScrollCheckBox->isChecked()) { double diff = (newmsec / 1000.0) - m_wideAxisRect->axis(QCPAxis::atBottom,0)->range().upper; m_wideAxisRect->axis(QCPAxis::atBottom,0)->setRangeLower(m_wideAxisRect->axis(QCPAxis::atBottom,0)->range().lower + diff); m_wideAxisRect->axis(QCPAxis::atBottom,0)->setRangeUpper((newmsec / 1000.0)); } if (!m_graphClassMap.contains("MODE")) { QCPAxis *axis = m_wideAxisRect->addAxis(QCPAxis::atLeft); axis->setLabel("MODE"); if (m_graphCount > 0) { connect(m_wideAxisRect->axis(QCPAxis::atLeft,0),SIGNAL(rangeChanged(QCPRange)),axis,SLOT(setRange(QCPRange))); } QColor color = QColor::fromRgb(rand()%255,rand()%255,rand()%255); axis->setLabelColor(color); axis->setTickLabelColor(color); axis->setTickLabelColor(color); // add an extra axis on the left and color its numbers QCPGraph *mainGraph1 = m_plot->addGraph(m_wideAxisRect->axis(QCPAxis::atBottom), m_wideAxisRect->axis(QCPAxis::atLeft,m_graphCount++)); m_graphNameList.append("MODE"); mainGraph1->setPen(QPen(color, 2)); Graph graph; graph.axis = axis; graph.groupName = ""; graph.graph= mainGraph1; graph.isInGroup = false; graph.isManualRange = false; m_graphClassMap["MODE"] = graph; mainGraph1->rescaleValueAxis(); if (m_graphCount == 1) { mainGraph1->rescaleKeyAxis(); } } QCPAxis *xAxis = m_wideAxisRect->axis(QCPAxis::atBottom); QCPItemText *itemtext = new QCPItemText(m_plot); itemtext->setText(text); itemtext->position->setAxes(xAxis,m_graphClassMap["MODE"].axis); itemtext->position->setCoords((newmsec / 1000.0),2.0); m_plot->addItem(itemtext); m_graphClassMap["MODE"].itemList.append(itemtext); m_graphClassMap["MODE"].modeMap[newmsec / 1000.0] = text; QCPItemLine *itemline = new QCPItemLine(m_plot); m_graphClassMap["MODE"].itemList.append(itemline); itemline->start->setParentAnchor(itemtext->bottom); itemline->start->setAxes(xAxis, m_graphClassMap["MODE"].axis); itemline->start->setCoords(0.0, 0.0); itemline->end->setAxes(xAxis, m_graphClassMap["MODE"].axis); itemline->end->setCoords((newmsec / 1000.0), 0.0); itemline->setTail(QCPLineEnding::esDisc); itemline->setHead(QCPLineEnding::esSpikeArrow); m_plot->addItem(itemline); }