18 #include <QApplication>
30 mController = controller;
32 mActiveToolId = QString();
40 void TrackingSystemPlaybackService::start()
42 if (!this->forceBaseToConfiguredState())
44 reportWarning(
"ToolManager must be configured before setting playback");
48 std::vector<ToolPtr> original;
49 for (
unsigned i=0; i<mBases.size(); ++i)
51 std::vector<ToolPtr> original_one = mBases[i]->getTools();
52 std::copy(original_one.begin(), original_one.end(), std::back_inserter(original));
57 for (
unsigned i=0; i<original.size(); ++i)
61 mTools.push_back(current);
64 if (!history->empty())
66 timeRange.first = std::min(timeRange.first, history->begin()->first);
67 timeRange.second = std::max(timeRange.second, history->rbegin()->first);
71 mController->initialize(QDateTime::fromMSecsSinceEpoch(timeRange.first), timeRange.second - timeRange.first);
73 report(
"Opened Playback Mode");
78 void TrackingSystemPlaybackService::stop()
82 report(
"Closed Playback Mode");
86 bool TrackingSystemPlaybackService::forceBaseToConfiguredState()
88 bool atLeastOneConfigured =
false;
90 for (
unsigned i=0; i<mBases.size(); ++i)
101 atLeastOneConfigured = atLeastOneConfigured || configured;
104 return atLeastOneConfigured;
113 for (
unsigned i=0; i<timeout/interval; ++i)
115 if (base->getState() == state)
117 qApp->processEvents();
124 std::vector<ToolPtr> retval;
125 std::copy(mTools.begin(), mTools.end(), back_inserter(retval));
134 bool TrackingSystemPlaybackService::isRunning()
const
136 return !mTools.empty();
145 if (!this->isRunning())
150 if (this->isRunning())
165 void TrackingSystemPlaybackService::onToolPositionChanged(
Transform3D matrix,
double timestamp)
169 if(mManual && (mManual->getUid() != mActiveToolId))
170 mManual->set_prMt(matrix, timestamp-1);