15 #include <QDomElement> 33 virtual void addXml(QDomNode& parentNode)
const 63 virtual std::vector<RegistrationTransform>
getData()
const 65 return std::vector<RegistrationTransform>();
69 return std::vector<ParentSpace>();
112 mTemp = tempTransform;
117 QDomDocument doc = parentNode.ownerDocument();
118 QDomElement base = doc.createElement(
"registrationTransform");
119 parentNode.appendChild(base);
122 base.setAttribute(
"type",
mType);
125 base.setAttribute(
"fixed",
mFixed);
127 base.setAttribute(
"moving",
mMoving);
134 if (dataNode.isNull())
137 QDomElement base = dataNode.toElement();
140 mType = base.attribute(
"type");
141 mValue = Transform3D::fromString(base.text());
142 mFixed = base.attribute(
"fixed");
143 mMoving = base.attribute(
"moving");
174 QDomDocument doc = parentNode.ownerDocument();
175 QDomElement base = doc.createElement(
"parentFrame");
176 parentNode.appendChild(base);
178 base.setAttribute(
"value", mUid);
180 base.setAttribute(
"type",
mType);
185 if (dataNode.isNull())
188 QDomElement base = dataNode.toElement();
191 mType = base.attribute(
"type");
192 mUid = base.attribute(
"value");
218 QDomDocument doc = parentNode.ownerDocument();
219 QDomElement base = doc.createElement(
"registrationHistory");
220 parentNode.appendChild(base);
222 QDomElement currentTime = doc.createElement(
"currentTime");
224 base.appendChild(currentTime);
226 for (
unsigned i = 0; i < mData.size(); ++i)
228 mData[i].addXml(base);
230 for (
unsigned i = 0; i < mParentSpaces.size(); ++i)
232 mParentSpaces[i].addXml(base);
238 if (dataNode.isNull())
242 QString currentTimeRaw = dataNode.namedItem(
"currentTime").toElement().text();
246 QDomElement currentElem = dataNode.firstChildElement(
"registrationTransform");
247 for (; !currentElem.isNull(); currentElem = currentElem.nextSiblingElement(
"registrationTransform"))
251 mData.push_back(transform);
255 currentElem = dataNode.firstChildElement(
"parentFrame");
256 for (; !currentElem.isNull(); currentElem = currentElem.nextSiblingElement(
"parentFrame"))
260 mParentSpaces.push_back(transform);
263 std::sort(mData.begin(), mData.end());
264 std::sort(mParentSpaces.begin(), mParentSpaces.end());
265 setActiveTime(currentTime);
271 mCurrentTime = QDateTime();
281 if (std::count(mData.begin(), mData.end(),
transform))
284 mData.push_back(transform);
285 std::sort(mData.begin(), mData.end());
287 bool silent = transform.
mTemp;
288 this->blockSignals(silent);
289 setActiveTime(QDateTime());
290 this->blockSignals(
false);
301 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end(); ++iter)
303 if ((iter->mTimestamp == oldTime)
311 this->addRegistrationInternal(newTransform);
328 emit currentChanged();
337 mParentSpaces.clear();
343 this->addParentSpace(
ParentSpace(newParent, QDateTime::currentDateTime(),
"Set Parent Frame"));
348 for (
int i = 0; i < mParentSpaces.size(); ++i)
350 if(mParentSpaces[i].mUid == newParent.
mUid)
354 mParentSpaces.push_back(newParent);
355 std::sort(mParentSpaces.begin(), mParentSpaces.end());
356 setActiveTime(QDateTime());
361 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end(); ++iter)
363 if (iter->mTimestamp != oldTime)
365 mParentSpaces.erase(iter);
368 this->addParentSpace(newParent);
373 return mParentSpaceCache;
383 return mParentSpaces;
388 if (!timestamp.isValid())
391 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end();)
393 if (iter->mTimestamp > timestamp)
398 iter = mData.erase(iter);
406 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end();)
408 if (iter->mTimestamp > timestamp)
412 << iter->mType <<
"]" << std::endl;
413 iter = mParentSpaces.erase(iter);
421 setActiveTime(QDateTime());
425 const QDateTime& timestamp)
427 if ((mTransformCache == val) && (mParentSpaceCache == parent) && (mCurrentTime == timestamp))
430 mCurrentTime = timestamp;
431 mTransformCache = val;
432 mParentSpaceCache = parent;
434 emit currentChanged();
445 if (timestamp.isValid())
447 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end(); ++iter)
449 if (iter->mTimestamp <= timestamp)
452 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end(); ++iter)
454 if (iter->mTimestamp <= timestamp)
462 if (!mParentSpaces.empty())
463 parent = mParentSpaces.back();
466 setCache(val, parent, timestamp);
476 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.