MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setProgress

Method setProgress

app/src/CSV/Player.cpp:426–454  ·  view source on GitHub ↗

* @brief Seeks playback to a normalized position between 0.0 and 1.0. */

Source from the content-addressed store, hash-verified

424 * @brief Seeks playback to a normalized position between 0.0 and 1.0.
425 */
426void CSV::Player::setProgress(const double progress)
427{
428 Q_ASSERT(progress >= 0.0 && progress <= 1.0);
429 Q_ASSERT(isOpen());
430
431 const auto validProgress = std::clamp(progress, 0.0, 1.0);
432
433 if (isPlaying())
434 pause();
435
436 if (frameCount() <= 0)
437 return;
438
439 int newFramePos = qMin(frameCount() - 1, qCeil(frameCount() * validProgress));
440
441 if (newFramePos != m_framePos) {
442 m_framePos = newFramePos;
443
444 UI::Dashboard::instance().clearPlotData();
445
446 int framesToLoad = UI::Dashboard::instance().points();
447 int startFrame = std::max(1, m_framePos - framesToLoad);
448 int endFrame = std::min(frameCount() - 1, m_framePos);
449
450 processFrameBatch(startFrame, endFrame);
451
452 updateData();
453 }
454}
455
456//--------------------------------------------------------------------------------------------------
457// Data processing

Callers

nothing calls this directly

Calls 3

clearPlotDataMethod · 0.80
clampFunction · 0.50
pointsMethod · 0.45

Tested by

no test coverage detected