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);
virtual std::vector< ToolPtr > getTools()
virtual void setLoggingFolder(QString loggingFolder)
virtual void setState(const Tool::State val)
asynchronously request a state. Wait for signal stateChanged()
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class PlaybackTool > PlaybackToolPtr
double getMilliSecondsSinceEpoch()
boost::shared_ptr< class ManualTool > ManualToolPtr
virtual TrackerConfigurationPtr getConfiguration()
void stateChanged()
Reset time synchronization. Used for resetting time synchronization of incoming timestamps in OpenIGT...
boost::shared_ptr< class PlaybackTime > PlaybackTimePtr
boost::shared_ptr< class TrackerConfiguration > TrackerConfigurationPtr
void reportWarning(QString msg)
static TrackerConfigurationPtr getNullObject()
boost::shared_ptr< TimedTransformMap > TimedTransformMapPtr
virtual Tool::State getState() const
void onActiveToolChanged(const QString &uId)
TrackingSystemPlaybackService(PlaybackTimePtr controller, std::vector< TrackingSystemServicePtr > base, ManualToolPtr manual)
virtual ~TrackingSystemPlaybackService()
Namespace for all CustusX production code.
boost::shared_ptr< class TrackingSystemService > TrackingSystemServicePtr