| 49 | void PlotBufferPreviewer::setManualDataLimits(bool enabled) { m_manualDataLimits = enabled; } |
| 50 | |
| 51 | void PlotBufferPreviewer::setupBufferPreviewer() |
| 52 | { |
| 53 | m_bufferPreviewer->setMinimumHeight(20); |
| 54 | m_bufferPreviewer->setCursorPos(0.5); |
| 55 | m_bufferPreviewer->setHighlightPos(0.05); |
| 56 | m_bufferPreviewer->setHighlightWidth(0.2); |
| 57 | m_bufferPreviewer->setCursorVisible(false); |
| 58 | m_bufferPreviewer->setWaveformPos(0.1); |
| 59 | m_bufferPreviewer->setWaveformWidth(0.5); |
| 60 | |
| 61 | updateDataLimits(m_plot->xAxis()->min(), m_plot->xAxis()->max()); |
| 62 | |
| 63 | connect(m_bufferPreviewer, &BufferPreviewer::bufferStartDrag, this, [=]() { |
| 64 | // reset the buffer preview position to current visible section |
| 65 | m_lastMin = m_plot->xAxis()->visibleMin(); |
| 66 | }); |
| 67 | |
| 68 | connect(m_bufferPreviewer, &BufferPreviewer::bufferMovedBy, this, [=](int bufferPos) { |
| 69 | double bufferWidth = m_bufferPreviewer->width(); |
| 70 | double axisWidth = m_bufferDataLimitMax - m_bufferDataLimitMin; |
| 71 | double newAxisPos = bufferPos * axisWidth / bufferWidth; |
| 72 | double axisOffset = m_lastMin - m_plot->xAxis()->visibleMin(); |
| 73 | if(axisWidth < 0) |
| 74 | axisOffset *= -1; |
| 75 | |
| 76 | double panAmount = PlotMagnifier::scaleToFactor(newAxisPos + axisOffset, m_plot->xAxis()->axisId(), |
| 77 | m_plot->plot()); |
| 78 | |
| 79 | bool bounded = m_plot->navigator()->isBounded(); |
| 80 | m_plot->navigator()->setBounded(false); |
| 81 | m_plot->navigator()->forcePan(m_plot->xAxis()->axisId(), panAmount); |
| 82 | m_plot->navigator()->setBounded(bounded); |
| 83 | updateBufferPreviewer(); |
| 84 | }); |
| 85 | |
| 86 | connect(m_bufferPreviewer, &BufferPreviewer::bufferResetPosition, this, [=]() { |
| 87 | Q_EMIT m_plot->navigator()->reset(); |
| 88 | updateBufferPreviewer(); |
| 89 | }); |
| 90 | |
| 91 | connect(m_plot->navigator(), &PlotNavigator::rectChanged, this, [=]() { updateBufferPreviewer(); }); |
| 92 | } |
| 93 | |
| 94 | void PlotBufferPreviewer::updateDataLimits(double min, double max) |
| 95 | { |
nothing calls this directly
no test coverage detected