36 #include <QDomElement> 54 virtual void addXml(QDomNode& parentNode)
const 84 virtual std::vector<RegistrationTransform>
getData()
const 86 return std::vector<RegistrationTransform>();
90 return std::vector<ParentSpace>();
133 mTemp = tempTransform;
138 QDomDocument doc = parentNode.ownerDocument();
139 QDomElement base = doc.createElement(
"registrationTransform");
140 parentNode.appendChild(base);
143 base.setAttribute(
"type",
mType);
146 base.setAttribute(
"fixed",
mFixed);
148 base.setAttribute(
"moving",
mMoving);
155 if (dataNode.isNull())
158 QDomElement base = dataNode.toElement();
161 mType = base.attribute(
"type");
162 mValue = Transform3D::fromString(base.text());
163 mFixed = base.attribute(
"fixed");
164 mMoving = base.attribute(
"moving");
195 QDomDocument doc = parentNode.ownerDocument();
196 QDomElement base = doc.createElement(
"parentFrame");
197 parentNode.appendChild(base);
199 base.setAttribute(
"value", mUid);
201 base.setAttribute(
"type",
mType);
206 if (dataNode.isNull())
209 QDomElement base = dataNode.toElement();
212 mType = base.attribute(
"type");
213 mUid = base.attribute(
"value");
239 QDomDocument doc = parentNode.ownerDocument();
240 QDomElement base = doc.createElement(
"registrationHistory");
241 parentNode.appendChild(base);
243 QDomElement currentTime = doc.createElement(
"currentTime");
245 base.appendChild(currentTime);
247 for (
unsigned i = 0; i < mData.size(); ++i)
249 mData[i].addXml(base);
251 for (
unsigned i = 0; i < mParentSpaces.size(); ++i)
253 mParentSpaces[i].addXml(base);
259 if (dataNode.isNull())
263 QString currentTimeRaw = dataNode.namedItem(
"currentTime").toElement().text();
267 QDomElement currentElem = dataNode.firstChildElement(
"registrationTransform");
268 for (; !currentElem.isNull(); currentElem = currentElem.nextSiblingElement(
"registrationTransform"))
272 mData.push_back(transform);
276 currentElem = dataNode.firstChildElement(
"parentFrame");
277 for (; !currentElem.isNull(); currentElem = currentElem.nextSiblingElement(
"parentFrame"))
281 mParentSpaces.push_back(transform);
284 std::sort(mData.begin(), mData.end());
285 std::sort(mParentSpaces.begin(), mParentSpaces.end());
286 setActiveTime(currentTime);
292 mCurrentTime = QDateTime();
302 if (std::count(mData.begin(), mData.end(),
transform))
305 mData.push_back(transform);
306 std::sort(mData.begin(), mData.end());
308 bool silent = transform.
mTemp;
309 this->blockSignals(silent);
310 setActiveTime(QDateTime());
311 this->blockSignals(
false);
322 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end(); ++iter)
324 if ((iter->mTimestamp == oldTime)
332 this->addRegistrationInternal(newTransform);
349 emit currentChanged();
358 mParentSpaces.clear();
364 this->addParentSpace(
ParentSpace(newParent, QDateTime::currentDateTime(),
"Set Parent Frame"));
369 for (
int i = 0; i < mParentSpaces.size(); ++i)
371 if(mParentSpaces[i].mUid == newParent.
mUid)
375 mParentSpaces.push_back(newParent);
376 std::sort(mParentSpaces.begin(), mParentSpaces.end());
377 setActiveTime(QDateTime());
382 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end(); ++iter)
384 if (iter->mTimestamp != oldTime)
386 mParentSpaces.erase(iter);
389 this->addParentSpace(newParent);
394 return mParentSpaceCache;
404 return mParentSpaces;
409 if (!timestamp.isValid())
412 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end();)
414 if (iter->mTimestamp > timestamp)
419 iter = mData.erase(iter);
427 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end();)
429 if (iter->mTimestamp > timestamp)
433 << iter->mType <<
"]" << std::endl;
434 iter = mParentSpaces.erase(iter);
442 setActiveTime(QDateTime());
446 const QDateTime& timestamp)
448 if ((mTransformCache == val) && (mParentSpaceCache == parent) && (mCurrentTime == timestamp))
451 mCurrentTime = timestamp;
452 mTransformCache = val;
453 mParentSpaceCache = parent;
455 emit currentChanged();
466 if (timestamp.isValid())
468 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end(); ++iter)
470 if (iter->mTimestamp <= timestamp)
473 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end(); ++iter)
475 if (iter->mTimestamp <= timestamp)
483 if (!mParentSpaces.empty())
484 parent = mParentSpaces.back();
487 setCache(val, parent, timestamp);
497 return mTransformCache;
QString qstring_cast(const T &val)
virtual void setRegistration(const Transform3D &transform)
bool operator<(const Landmark &lhs, const Landmark &rhs)
virtual std::vector< RegistrationTransform > getData() const
virtual void setParentSpace(const QString &newParent)
DoubleBoundingBox3D transform(const Transform3D &m, const DoubleBoundingBox3D &bb)
virtual ParentSpace getCurrentParentSpace()
boost::shared_ptr< class RegistrationHistory > RegistrationHistoryPtr
Definition of a parent space event.
virtual void addXml(QDomNode &parentNode) const
write internal state to node
static RegistrationHistoryPtr getNullObject()
virtual void setParentSpace(const QString &newParent)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
virtual void addOrUpdateRegistration(const RegistrationTransform &transform)
QString timestampSecondsFormatNice()
virtual void updateParentSpace(const QDateTime &oldTime, const ParentSpace &newParent)
virtual void setActiveTime(const QDateTime ×tamp)
virtual bool isNull() const
virtual QDateTime getActiveTime() const
QString timestampSecondsFormat()
QString mUid
parent frame uid
virtual void clear()
reset all data loaded from xml
virtual void addXml(QDomNode &parentNode) const
write internal state to node
virtual std::vector< ParentSpace > getParentSpaces() const
QDateTime mTimestamp
time the transform was registrated.
virtual void addParentSpace(const QString &newParent)
void parseXml(QDomNode &dataNode)
read internal state from node
virtual std::vector< RegistrationTransform > getData() const
void addXml(QDomNode &parentNode) const
write internal state to node
virtual QDateTime getActiveTime() const
virtual RegistrationTransform getCurrentRegistration() const
virtual void removeNewerThan(const QDateTime ×tamp)
QString mType
description of the kind if registration (manual, patient, landmark, coregistration etc) ...
virtual void removeNewerThan(const QDateTime ×tamp)
virtual ParentSpace getCurrentParentSpace()
virtual void clear()
reset all data loaded from xml
virtual void updateParentSpace(const QDateTime &oldTime, const ParentSpace &newParent)
bool operator==(const RegistrationTransform &lhs, const RegistrationTransform &rhs)
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
virtual RegistrationTransform getCurrentRegistration() const
virtual std::vector< ParentSpace > getParentSpaces() const
virtual void parseXml(QDomNode &dataNode)
read internal state from node
virtual void parseXml(QDomNode &dataNode)
read internal state from node
virtual void addOrUpdateRegistration(const QDateTime &oldTime, const RegistrationTransform &newTransform)
virtual void addOrUpdateRegistration(const QDateTime &oldTime, const RegistrationTransform &newTransform)
virtual void setActiveTime(const QDateTime ×tamp)
virtual void addParentSpace(const ParentSpace &newParent)
virtual void addParentSpace(const QString &newParent)
virtual void setRegistration(const Transform3D &transform)
A history of registration events.
Namespace for all CustusX production code.