18 #include <QApplication> 30 mController = controller;
39 void TrackingSystemPlaybackService::start()
41 if (!this->forceBaseToConfiguredState())
43 reportWarning(
"ToolManager must be configured before setting playback");
47 std::vector<ToolPtr> original;
48 for (
unsigned i=0; i<mBases.size(); ++i)
50 std::vector<ToolPtr> original_one = mBases[i]->getTools();
51 std::copy(original_one.begin(), original_one.end(), std::back_inserter(original));
56 for (
unsigned i=0; i<original.size(); ++i)
60 mTools.push_back(current);
63 if (!history->empty())
65 timeRange.first = std::min(timeRange.first, history->begin()->first);
66 timeRange.second = std::max(timeRange.second, history->rbegin()->first);
70 mController->initialize(QDateTime::fromMSecsSinceEpoch(timeRange.first), timeRange.second - timeRange.first);
72 report(
"Opened Playback Mode");
77 void TrackingSystemPlaybackService::stop()
81 report(
"Closed Playback Mode");
85 bool TrackingSystemPlaybackService::forceBaseToConfiguredState()
87 bool atLeastOneConfigured =
false;
89 for (
unsigned i=0; i<mBases.size(); ++i)
100 atLeastOneConfigured = atLeastOneConfigured || configured;
103 return atLeastOneConfigured;
112 for (
unsigned i=0; i<timeout/interval; ++i)
114 if (base->getState() == state)
116 qApp->processEvents();
123 std::vector<ToolPtr> retval;
124 std::copy(mTools.begin(), mTools.end(), back_inserter(retval));
133 bool TrackingSystemPlaybackService::isRunning()
const 135 return !mTools.empty();
144 if (!this->isRunning())
149 if (this->isRunning())
164 void TrackingSystemPlaybackService::onToolPositionChanged(
Transform3D matrix,
double timestamp)
168 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()
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
TrackingSystemPlaybackService(PlaybackTimePtr controller, std::vector< TrackingSystemServicePtr > base, ManualToolPtr manual)
virtual ~TrackingSystemPlaybackService()
Namespace for all CustusX production code.
boost::shared_ptr< class TrackingSystemService > TrackingSystemServicePtr