36 #include <QDomElement>
53 virtual void addXml(QDomNode& parentNode)
const
83 virtual std::vector<RegistrationTransform>
getData()
const
85 return std::vector<RegistrationTransform>();
89 return std::vector<ParentSpace>();
136 QDomDocument doc = parentNode.ownerDocument();
137 QDomElement base = doc.createElement(
"registrationTransform");
138 parentNode.appendChild(base);
141 base.setAttribute(
"type", mType);
143 if (!mFixed.isEmpty())
144 base.setAttribute(
"fixed", mFixed);
145 if (!mMoving.isEmpty())
146 base.setAttribute(
"moving", mMoving);
148 base.appendChild(doc.createTextNode(
"\n" +
qstring_cast(mValue)));
153 if (dataNode.isNull())
156 QDomElement base = dataNode.toElement();
159 mType = base.attribute(
"type");
160 mValue = Transform3D::fromString(base.text());
161 mFixed = base.attribute(
"fixed");
162 mMoving = base.attribute(
"moving");
193 QDomDocument doc = parentNode.ownerDocument();
194 QDomElement base = doc.createElement(
"parentFrame");
195 parentNode.appendChild(base);
197 base.setAttribute(
"value", mValue);
199 base.setAttribute(
"type", mType);
204 if (dataNode.isNull())
207 QDomElement base = dataNode.toElement();
210 mType = base.attribute(
"type");
211 mValue = base.attribute(
"value");
237 QDomDocument doc = parentNode.ownerDocument();
238 QDomElement base = doc.createElement(
"registrationHistory");
239 parentNode.appendChild(base);
241 QDomElement currentTime = doc.createElement(
"currentTime");
243 base.appendChild(currentTime);
245 for (
unsigned i = 0; i < mData.size(); ++i)
247 mData[i].addXml(base);
249 for (
unsigned i = 0; i < mParentSpaces.size(); ++i)
251 mParentSpaces[i].addXml(base);
257 if (dataNode.isNull())
261 QString currentTimeRaw = dataNode.namedItem(
"currentTime").toElement().text();
265 QDomElement currentElem = dataNode.firstChildElement(
"registrationTransform");
266 for (; !currentElem.isNull(); currentElem = currentElem.nextSiblingElement(
"registrationTransform"))
270 mData.push_back(transform);
274 currentElem = dataNode.firstChildElement(
"parentFrame");
275 for (; !currentElem.isNull(); currentElem = currentElem.nextSiblingElement(
"parentFrame"))
279 mParentSpaces.push_back(transform);
282 std::sort(mData.begin(), mData.end());
283 std::sort(mParentSpaces.begin(), mParentSpaces.end());
290 mCurrentTime = QDateTime();
298 if (std::count(mData.begin(), mData.end(),
transform))
301 mData.push_back(transform);
302 std::sort(mData.begin(), mData.end());
311 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end(); ++iter)
313 if ((iter->mTimestamp == oldTime)
315 && (iter->mType == newTransform.
mType))
347 mParentSpaces.clear();
358 if (std::count(mParentSpaces.begin(), mParentSpaces.end(), newParent))
361 mParentSpaces.push_back(newParent);
362 std::sort(mParentSpaces.begin(), mParentSpaces.end());
368 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end(); ++iter)
370 if (iter->mTimestamp != oldTime)
372 mParentSpaces.erase(iter);
380 return mParentSpaceCache;
390 return mParentSpaces;
395 if (!timestamp.isValid())
398 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end();)
400 if (iter->mTimestamp > timestamp)
405 iter = mData.erase(iter);
413 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end();)
415 if (iter->mTimestamp > timestamp)
419 << iter->mType <<
"]" << std::endl;
420 iter = mParentSpaces.erase(iter);
432 const QDateTime& timestamp)
434 if ((mTransformCache == val) && (mParentSpaceCache == parent) && (mCurrentTime == timestamp))
437 mCurrentTime = timestamp;
438 mTransformCache = val;
439 mParentSpaceCache = parent;
452 if (timestamp.isValid())
454 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end(); ++iter)
456 if (iter->mTimestamp <= timestamp)
459 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end(); ++iter)
461 if (iter->mTimestamp <= timestamp)
469 if (!mParentSpaces.empty())
470 parent = mParentSpaces.back();
473 setCache(val, parent, timestamp);
483 return mTransformCache;
QString qstring_cast(const T &val)
QString mValue
parent frame uid
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.
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()
virtual void clear()
reset all data loaded from xml
bool similar(const DoubleBoundingBox3D &a, const DoubleBoundingBox3D &b, double tol)
virtual void addXml(QDomNode &parentNode) const
write internal state to node
virtual std::vector< ParentSpace > getParentSpaces() const
virtual void updateRegistration(const QDateTime &oldTime, const RegistrationTransform &newTransform)
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 void addRegistration(const RegistrationTransform &transform)
virtual void addRegistration(const RegistrationTransform &transform)
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)
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 setActiveTime(const QDateTime ×tamp)
virtual void updateRegistration(const QDateTime &oldTime, const RegistrationTransform &newTransform)
virtual void addParentSpace(const ParentSpace &newParent)
virtual void addParentSpace(const QString &newParent)
virtual void setRegistration(const Transform3D &transform)
A history of registration events.