13 #include <QDomDocument> 14 #include <QDomElement> 44 QDateTime time = QDateTime::currentDateTime();
52 QDateTime time = QDateTime::currentDateTime();
70 QString format(
"hh:mm");
73 return QString(
"%1 %2 %3")
83 return QString(
"%1_%2")
84 .arg(
mId, 2, 10, QChar(
'0'))
91 return QString(
"%1_%2_%3")
100 adder.
node().toElement().setAttribute(
"uid", this->
getUid());
105 QDomElement interval = adder.
addElement(
"interval");
127 QDomElement base = node.toElement();
133 for (
unsigned i=0; i<intervals.size(); ++i)
135 QDomElement source = intervals[i].toElement();
156 return node.firstChildElement(
"description").isElement();
161 if (parentNode.isNull())
163 reportWarning(
"RecordSession::parseXml() parentnode is null");
167 QDomElement base = parentNode.toElement();
169 QString uid = base.attribute(
"uid");
172 double starttime = parentNode.namedItem(
"start").toElement().text().toDouble(&ok);
173 double stoptime = parentNode.namedItem(
"stop").toElement().text().toDouble(&ok);
174 QString description = parentNode.namedItem(
"description").toElement().text();
176 mCategory = description.split(
"_"+uid).first();
178 mIntervals.push_back(std::make_pair(QDateTime::fromMSecsSinceEpoch(starttime),
179 QDateTime::fromMSecsSinceEpoch(stoptime)));
184 mId = uid.split(
"_").first().toInt();
194 for (
unsigned i=0; i<session->mIntervals.size(); ++i)
197 values = tool->getSessionHistory(session->mIntervals[i].first.toMSecsSinceEpoch(),
198 session->mIntervals[i].second.toMSecsSinceEpoch());
199 retval.insert(values.begin(), values.end());
203 if(retval.empty() && session && verbose)
205 CX_LOG_ERROR() << QString(
"Could not find any tracking data for tool [%1] in session [%2]. ")
206 .arg(tool.get() ? tool->getName() :
"NULL")
207 .arg(session.get() ? session->getHumanDescription() :
"NULL");
215 std::map<double, cx::ToolPositionMetadata> retval;
219 for (
unsigned i=0; i<session->mIntervals.size(); ++i)
221 double startTime = session->mIntervals[i].first.toMSecsSinceEpoch();
222 double stopTime = session->mIntervals[i].second.toMSecsSinceEpoch();
223 const std::map<double, cx::ToolPositionMetadata>&
values = tool->getMetadataHistory();
225 retval.insert(values.lower_bound(startTime),
226 values.upper_bound(stopTime));
230 if(retval.empty() && session && verbose)
232 CX_LOG_ERROR() << QString(
"Could not find any tracking meta data for tool [%1] in session [%2]. ")
233 .arg(tool.get() ? tool->getName() :
"NULL")
234 .arg(session.get() ? session->getHumanDescription() :
"NULL");
static std::map< double, ToolPositionMetadata > getToolHistory_metadata(ToolPtr tool, RecordSessionPtr session, bool verbose)
void cancelLastInterval()
std::pair< QDateTime, QDateTime > IntervalType
QDomElement addElement(QString name)
unsigned getIntervalCount() const
QString timestampMilliSecondsFormat()
std::vector< QDomElement > getDuplicateElements(QString name)
QDateTime timestamp2datetime(QString in) const
void addXml(QDomNode &node)
void setIdAndTimestampFromUid(QString uid)
std::vector< IntervalType > mIntervals
QString timestampSecondsFormat()
static TimedTransformMap getToolHistory_prMt(ToolPtr tool, RecordSessionPtr session, bool verbose)
boost::shared_ptr< class RecordSession > RecordSessionPtr
void reportWarning(QString msg)
std::pair< QDateTime, QDateTime > getInterval(int i)
QDomElement addTextToElement(QString name, QString text)
QString getHumanDescription() const
description useful for display in gui.
bool isOldStyleXmlFormat(QDomNode &node)
QString getDescription() const
another legacy uid, used for folder creation etc
CompositeGenerator< T > values(T val1, T val2)
QString parseTextFromElement(QString name)
QDateTime getTimestamp() const
void parseXml_oldstyle(QDomNode &parentNode)
QString datetime2timestamp(QDateTime in) const
void parseXml(QDomNode &node)
std::map< double, Transform3D > TimedTransformMap
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr