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);
124 if (!mFixed.isEmpty())
125 base.setAttribute(
"fixed", mFixed);
126 if (!mMoving.isEmpty())
127 base.setAttribute(
"moving", mMoving);
129 base.appendChild(doc.createTextNode(
"\n" +
qstring_cast(mValue)));
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"))
255 currentElem = dataNode.firstChildElement(
"parentFrame");
256 for (; !currentElem.isNull(); currentElem = currentElem.nextSiblingElement(
"parentFrame"))
263 std::sort(mData.begin(), mData.end());
264 std::sort(mParentSpaces.begin(), mParentSpaces.end());
271 mCurrentTime = QDateTime();
281 if (std::count(mData.begin(), mData.end(),
transform))
285 std::sort(mData.begin(), mData.end());
299 for (std::vector<RegistrationTransform>::iterator iter = mData.begin(); iter != mData.end(); ++iter)
301 if ((iter->mTimestamp == oldTime)
309 this->addRegistrationInternal(newTransform);
335 mParentSpaces.clear();
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());
359 for (std::vector<ParentSpace>::iterator iter = mParentSpaces.begin(); iter != mParentSpaces.end(); ++iter)
361 if (iter->mTimestamp != oldTime)
363 mParentSpaces.erase(iter);
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);
423 const QDateTime& timestamp)
425 if ((mTransformCache == val) && (mParentSpaceCache == parent) && (mCurrentTime == timestamp))
428 mCurrentTime = timestamp;
429 mTransformCache = val;
430 mParentSpaceCache = parent;
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;