13 #include <QStringList> 16 #include <boost/bind.hpp> 17 #include "vtkImageImport.h" 18 #include "vtkImageData.h" 33 #include <QtConcurrent> 41 mVideoSourceUid(
"playback " + type)
46 mVideoSource->setStatusString(QString(
"No US Acquisition"));
48 connect(&mUSImageDataFutureWatcher, SIGNAL(finished()),
this, SLOT(usDataLoadFinishedSlot()));
63 return mTimer ?
true :
false;
69 disconnect(mTimer.get(), SIGNAL(changed()),
this, SLOT(timerChangedSlot()));
72 connect(mTimer.get(), SIGNAL(changed()),
this, SLOT(timerChangedSlot()));
76 mVideoSource->start();
80 mVideoSource->deconfigure();
92 std::vector<TimelineEvent> events;
94 QStringList allFiles = this->getAbsolutePathToFtsFiles(mRoot);
95 for (
int i=0; i<allFiles.size(); ++i)
100 if (timestamps.empty())
104 QString(
"Acquisition %1").arg(QFileInfo(allFiles[i]).fileName()),
105 timestamps.front().mTime,
106 timestamps.back().mTime);
107 current.
mUid = allFiles[i];
108 current.mGroup =
"acquisition";
109 current.mColor = QColor::fromHsv(36, 255, 222);
111 events.push_back(current);
120 QStringList USAcquisitionVideoPlayback::getAbsolutePathToFtsFiles(QString folder)
130 void USAcquisitionVideoPlayback::timerChangedSlot()
133 for (
unsigned i=0; i<mEvents.size(); ++i)
135 if (mEvents[i].isInside(mTimer->getTime().toMSecsSinceEpoch()))
142 this->loadFullData(event.
mUid);
143 this->updateFrame(event.
mUid);
146 void USAcquisitionVideoPlayback::loadFullData(QString filename)
152 mVideoSource->setInfoString(QString(
""));
153 mVideoSource->setStatusString(QString(
"No US Acquisition"));
154 mVideoSource->deconfigure();
157 if (filename.isEmpty())
164 if (filename.isEmpty())
169 if (!mUSImageDataReader)
173 mUSImageDataFutureWatcher.setFuture(mUSImageDataFutureResult);
177 void USAcquisitionVideoPlayback::usDataLoadFinishedSlot()
180 mCurrentData = mUSImageDataFutureResult.result();
183 mUSImageDataReader.reset();
185 mVideoSource->start();
188 ToolPtr tool = mBackend->tracking()->getFirstProbe();
197 mCurrentTimestamps.clear();
198 for (
unsigned i=0; i<mCurrentData.
mFrames.size(); ++i)
199 mCurrentTimestamps.push_back(mCurrentData.
mFrames[i].mTime);
201 this->updateFrame(mCurrentData.
mFilename);
204 void USAcquisitionVideoPlayback::updateFrame(QString filename)
206 if (mUSImageDataReader)
208 mVideoSource->setInfoString(QString(
"Loading US Data..."));
209 mVideoSource->setStatusString(QString(
"Loading US Data..."));
216 mVideoSource->setInfoString(QString(
""));
217 mVideoSource->setStatusString(QString(
"No US Acquisition"));
223 mVideoSource->start();
225 double timestamp = mTimer->getTime().toMSecsSinceEpoch();
228 std::vector<double>::iterator iter = std::lower_bound(mCurrentTimestamps.begin(), mCurrentTimestamps.end(), timestamp);
229 if (iter==mCurrentTimestamps.begin())
232 int index = std::distance(mCurrentTimestamps.begin(), iter);
235 mVideoSource->overrideTimeout(fabs(timestamp-*iter)>timeout);
237 ImagePtr image(
new Image(mVideoSourceUid, mCurrentData.
mUsRaw->getImageContainer()->get(index)));
238 image->setAcquisitionTime(QDateTime::fromMSecsSinceEpoch(timestamp));
240 mVideoSource->setInfoString(QString(
"%1 - Frame %2").arg(mCurrentData.
mUsRaw->getName()).arg(index));
241 if (mVideoSource->validData())
242 mVideoSource->setStatusString(QString(
""));
244 mVideoSource->setStatusString(QString(
"Timeout"));
246 mVideoSource->setInput(image);
Reader class for the US Acquisition files.
void setTime(PlaybackTimePtr controller)
Description of one event in time.
boost::shared_ptr< class Image > ImagePtr
std::vector< TimedPosition > readFrameTimestamps(QString fileName)
VideoSourcePtr getVideoSource()
boost::shared_ptr< class VideoServiceBackend > VideoServiceBackendPtr
void setRoot(const QString path)
boost::shared_ptr< class PlaybackTime > PlaybackTimePtr
boost::shared_ptr< Probe > ProbePtr
USReconstructInputData readAllFiles(QString fileName, QString calFilesPath="")
boost::shared_ptr< class VideoSource > VideoSourcePtr
USAcquisitionVideoPlayback(VideoServiceBackendPtr backend, QString type)
VideoSource controlled by a vtkImageData.
std::vector< TimelineEvent > getEvents()
QStringList getAbsolutePathToFiles(QString path, QStringList nameFilters, bool includeSubDirs)
virtual ~USAcquisitionVideoPlayback()
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr