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 setActiveTime(QDateTime());
299 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end(); ++iter)
301 if ((iter->mTimestamp == oldTime)
309 this->addRegistrationInternal(newTransform);
326 emit currentChanged();
335 mParentSpaces.clear();
341 this->addParentSpace(
ParentSpace(newParent, QDateTime::currentDateTime(),
"Set Parent Frame"));
346 for (
int i = 0; i < mParentSpaces.size(); ++i)
348 if(mParentSpaces[i].mUid == newParent.
mUid)
352 mParentSpaces.push_back(newParent);
353 std::sort(mParentSpaces.begin(), mParentSpaces.end());
354 setActiveTime(QDateTime());
359 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end(); ++iter)
361 if (iter->mTimestamp != oldTime)
363 mParentSpaces.erase(iter);
366 this->addParentSpace(newParent);
371 return mParentSpaceCache;
381 return mParentSpaces;
386 if (!timestamp.isValid())
389 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end();)
391 if (iter->mTimestamp > timestamp)
396 iter = mData.erase(iter);
404 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end();)
406 if (iter->mTimestamp > timestamp)
410 << iter->mType <<
"]" << std::endl;
411 iter = mParentSpaces.erase(iter);
419 setActiveTime(QDateTime());
423 const QDateTime& timestamp)
425 if ((mTransformCache == val) && (mParentSpaceCache == parent) && (mCurrentTime == timestamp))
428 mCurrentTime = timestamp;
429 mTransformCache = val;
430 mParentSpaceCache = parent;
432 emit currentChanged();
443 if (timestamp.isValid())
445 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end(); ++iter)
447 if (iter->mTimestamp <= timestamp)
450 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end(); ++iter)
452 if (iter->mTimestamp <= timestamp)
460 if (!mParentSpaces.empty())
461 parent = mParentSpaces.back();
464 setCache(val, parent, timestamp);
474 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.