CustusX  2020.11.07-dev+develop.4ce4a
An IGT application
cxTrackingImplService.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #define _USE_MATH_DEFINES
13 
14 #include "cxTrackingImplService.h"
15 
16 #include "boost/bind.hpp"
17 
18 #include <QTimer>
19 #include <QDir>
20 #include <QList>
21 #include <QMetaType>
22 #include <QFileInfo>
23 #include <vtkDoubleArray.h>
24 #include <QCoreApplication>
25 
27 #include "cxLogger.h"
28 #include "cxTypeConversions.h"
29 #include "cxPositionStorageFile.h"
30 #include "cxTime.h"
31 #include "cxDummyTool.h"
32 #include "cxToolImpl.h"
34 #include "cxManualToolAdapter.h"
35 #include "cxSettings.h"
36 #include "cxPlaybackTool.h"
37 
38 #include "cxPlaybackTime.h"
40 #include "cxXMLNodeWrapper.h"
42 #include "cxUtilHelpers.h"
43 
47 
48 #include "cxNullDeleter.h"
49 
50 namespace cx
51 {
52 
53 TrackingImplService::TrackingImplService(ctkPluginContext *context) :
54  mLastLoadPositionHistory(0),
55  mContext(context),
56  mToolTipOffset(0)
57 {
58  mSession = SessionStorageServiceProxy::create(mContext);
59  connect(mSession.get(), &SessionStorageService::sessionChanged, this, &TrackingImplService::onSessionChanged);
60  connect(mSession.get(), &SessionStorageService::cleared, this, &TrackingImplService::onSessionCleared);
61  connect(mSession.get(), &SessionStorageService::isLoading, this, &TrackingImplService::onSessionLoad);
62  connect(mSession.get(), &SessionStorageService::isSaving, this, &TrackingImplService::onSessionSave);
63 
64  this->initializeManualTool(); // do this after setting self.
65 
66  connect(settings(), SIGNAL(valueChangedFor(QString)), this, SLOT(globalConfigurationFileChangedSlot(QString)));
67 
68  this->listenForTrackingSystemServices(context);
69 }
70 
72 {
73  while (!mTrackingSystems.empty())
74  this->unInstallTrackingSystem(mTrackingSystems.back());
75 }
76 
77 
79 {
80  return false;
81 }
82 
83 void TrackingImplService::onSystemStateChanged()
84 {
85  this->rebuildCachedTools();
86  emit stateChanged();
87 }
88 
96 {
97  // playback off, reinstall old tracking systems
98  if (mPlaybackSystem)
99  {
100  mPlaybackSystem->setState(Tool::tsNONE);
101  this->unInstallTrackingSystem(mPlaybackSystem);
102  std::vector<TrackingSystemServicePtr> old = mPlaybackSystem->getBase();
103  for (unsigned i=0; i<old.size(); ++i)
104  this->installTrackingSystem(old[i]);
105  mPlaybackSystem.reset();
106  }
107 
108  // uninstall tracking systems, playback on
109  if (controller)
110  {
111  mPlaybackSystem.reset(new TrackingSystemPlaybackService(controller, mTrackingSystems, mManualTool));
112  std::vector<TrackingSystemServicePtr> old = mPlaybackSystem->getBase();
113  for (unsigned i=0; i<old.size(); ++i)
114  this->unInstallTrackingSystem(old[i]);
115  this->installTrackingSystem(mPlaybackSystem);
116  mPlaybackSystem->setState(Tool::tsTRACKING);
117  }
118 }
119 
121 {
122  return mPlaybackSystem && (mPlaybackSystem->getState()>=Tool::tsCONFIGURED);
123 }
124 
126 {
127  TrackingSystemServicePtr dummySystem;
128  dummySystem.reset(new TrackingSystemDummyService(tool));
129  this->installTrackingSystem(dummySystem);
130 
131  dummySystem->setState(Tool::tsTRACKING);
132  this->setActiveTool(tool->getUid());
133 }
134 
136 {
137  mTrackingSystems.push_back(system);
138  report("Installing tracking system: " + system->getUid());
139  connect(system.get(), &TrackingSystemService::stateChanged, this, &TrackingImplService::onSystemStateChanged);
140  this->onSystemStateChanged();
141 }
142 
144 {
145  report("Uninstalling tracking system: " + system->getUid());
146  disconnect(system.get(), &TrackingSystemService::stateChanged, this, &TrackingImplService::onSystemStateChanged);
147 
148  for (unsigned i=0; i<mTrackingSystems.size(); ++i)
149  {
150  if (mTrackingSystems[i]!=system)
151  continue;
152  mTrackingSystems.erase(mTrackingSystems.begin()+i);
153  break;
154  }
155 
156  this->onSystemStateChanged();
157 }
158 
159 std::vector<TrackingSystemServicePtr> TrackingImplService::getTrackingSystems()
160 {
161  return mTrackingSystems;
162 }
163 
164 void TrackingImplService::initializeManualTool()
165 {
166  if (!mManualTool)
167  {
168  //adding a manual tool as default
169  mManualTool.reset(new ManualToolAdapter("ManualTool"));
170  mTools["ManualTool"] = mManualTool;
171  mManualTool->setVisible(true);
172  connect(mManualTool.get(), &Tool::toolVisible, this, &TrackingImplService::activeCheckSlot);
173  connect(mManualTool.get(), &Tool::toolTransformAndTimestamp, this, &TrackingImplService::activeCheckSlot);
174  connect(mManualTool.get(), &Tool::tooltipOffset, this, &TrackingImplService::onTooltipOffset);
175  }
176 
177  Transform3D rMpr = Transform3D::Identity(); // not known: not really important either
179  mManualTool->set_prMt(prMt);
180  this->activeCheckSlot();
181 }
182 
184 {
185  Tool::State state = Tool::tsNONE;
186  for (unsigned i=0; i<mTrackingSystems.size(); ++i)
187  state = std::max(state, mTrackingSystems[i]->getState());
188  return state;
189 }
190 
192 {
193  for (unsigned i=0; i<mTrackingSystems.size(); ++i)
194  mTrackingSystems[i]->setState(val);
195 }
196 
197 void TrackingImplService::listenForTrackingSystemServices(ctkPluginContext *context)
198 {
199  mServiceListener.reset(new ServiceTrackerListener<TrackingSystemService>(
200  context,
201  boost::bind(&TrackingImplService::onTrackingSystemAdded, this, _1),
202  boost::bind(&TrackingImplService::onTrackingSystemModified, this, _1),
203  boost::bind(&TrackingImplService::onTrackingSystemRemoved, this, _1)
204  ));
205  mServiceListener->open();
206 }
207 
208 void TrackingImplService::onTrackingSystemAdded(TrackingSystemService* service)
209 {
211 }
212 
213 void TrackingImplService::onTrackingSystemRemoved(TrackingSystemService* service)
214 {
216 }
217 
218 void TrackingImplService::onTrackingSystemModified(TrackingSystemService* service)
219 {
220  Q_UNUSED(service);
221 }
222 
223 void TrackingImplService::rebuildCachedTools()
224 {
225  mTools.clear();
226  for (unsigned i=0; i<mTrackingSystems.size(); ++i)
227  {
228  this->addToolsFrom(mTrackingSystems[i]);
229  }
230  mTools[mManualTool->getUid()] = mManualTool;
231  this->imbueManualToolWithRealProperties();
232  this->loadPositionHistory(); // the tools are always reconfigured after a setloggingfolder
233  this->resetTrackingPositionFilters();
234  this->onTooltipOffset(mToolTipOffset);
235  this->setActiveTool(this->getManualTool()->getUid()); // this emits a signal: call after all other initialization
236 }
237 
238 void TrackingImplService::imbueManualToolWithRealProperties()
239 {
240  // debug: give the manual tool properties from the first non-manual tool. Nice for testing tools
241  if (!settings()->value("giveManualToolPhysicalProperties").toBool())
242  return;
243 
244  for (ToolMap::iterator iter = mTools.begin(); iter != mTools.end(); ++iter)
245  {
246  if (iter->second == mManualTool)
247  continue;
248  if (iter->second->hasType(Tool::TOOL_REFERENCE))
249  continue;
250  mManualTool->setBase(iter->second);
251  mManualTool->startEmittingContinuousPositions(100);
252 
253  report("Manual tool imbued with properties from " + iter->first);
254  break;
255  }
256 }
257 
258 void TrackingImplService::addToolsFrom(TrackingSystemServicePtr system)
259 {
260  std::vector<ToolPtr> tools = system->getTools();
261  for (unsigned i=0; i<tools.size(); ++i)
262  {
263  ToolPtr tool = tools[i];
264  mTools[tool->getUid()] = tool;
265  connect(tool.get(), SIGNAL(toolVisible(bool)), this, SLOT(activeCheckSlot()));
266  connect(tool.get(), &Tool::toolTransformAndTimestamp, this, &TrackingImplService::activeCheckSlot);
267  connect(tool.get(), &Tool::tooltipOffset, this, &TrackingImplService::onTooltipOffset);
268 
269  if (tool->hasType(Tool::TOOL_REFERENCE))
270  mReferenceTool = tool;
271  }
272 }
273 
274 void TrackingImplService::onTooltipOffset(double val)
275 {
276  mToolTipOffset = val;
277  for (ToolMap::iterator iter = mTools.begin(); iter != mTools.end(); ++iter)
278  {
279  iter->second->setTooltipOffset(val);
280  }
281 }
282 
284 {
285  SessionToolHistoryMap retval;
286 
287  ToolMap tools = this->getTools();
288  ToolMap::iterator it = tools.begin();
289  for (; it != tools.end(); ++it)
290  {
291  TimedTransformMap toolMap = it->second->getSessionHistory(startTime, stopTime);
292  if (toolMap.empty())
293  continue;
294  retval[it->second] = toolMap;
295  }
296  return retval;
297 }
298 
300 {
301  return mTools;
302 }
303 
305 {
306  if (uid == "active")
307  return this->getActiveTool();
308 
309  ToolPtr retval;
310  ToolMap::iterator it = mTools.find(uid);
311  if (it != mTools.end())
312  retval = it->second;
313 
314  return retval;
315 }
316 
318 {
319  return mActiveTool;
320 }
321 
322 void TrackingImplService::setActiveTool(const QString& uid)
323 {
324  if (mActiveTool && mActiveTool->getUid() == uid)
325  return;
326 
327  ToolPtr newTool;
328  newTool = this->getTool(uid);
329 
330  ToolPtr oldTool = mActiveTool;
331  mActiveTool = newTool; // set active before calling setters, which possibly can emit signal and cause cycles.
332 
333  // special case for manual tool
334  if (newTool && newTool->hasType(Tool::TOOL_MANUAL) && mManualTool)
335  {
336  if (oldTool && (oldTool!=mManualTool))
337  mManualTool->set_prMt(oldTool->get_prMt(), oldTool->getTimestamp() -1);
338  mManualTool->setVisible(true);
339  }
340  else
341  {
342  mManualTool->setVisible(false);
343  }
344 
345  emit activeToolChanged(uid);
346 }
347 
349 {
350  return mReferenceTool;
351 }
352 
353 void TrackingImplService::savePositionHistory()
354 {
355  QString filename = this->getLoggingFolder() + "/toolpositions.snwpos";
356 
357  PositionStorageWriter writer(filename);
358 
359  ToolMap::iterator it = mTools.begin();
360  for (; it != mTools.end(); ++it)
361  {
362  ToolPtr current = it->second;
363  TimedTransformMapPtr data = current->getPositionHistory();
364 
365  if (!data)
366  continue;
367 
368  // save only data acquired after mLastLoadPositionHistory:
369  TimedTransformMap::iterator iter = data->lower_bound(mLastLoadPositionHistory);
370  for (; iter != data->end(); ++iter)
371  writer.write(iter->second, (iter->first), current->getUid());
372  }
373 
374  mLastLoadPositionHistory = getMilliSecondsSinceEpoch();
375 }
376 
377 void TrackingImplService::loadPositionHistory()
378 {
379  if (this->getState()==Tool::tsNONE)
380  return;
381  // save all position data acquired so far, in case of multiple calls.
382  this->savePositionHistory();
383 
384  QString filename = this->getLoggingFolder()+ "/toolpositions.snwpos";
385 
386  PositionStorageReader reader(filename);
387 
388  Transform3D matrix = Transform3D::Identity();
389  double timestamp;
390  QString toolUid;
391 
392  QStringList missingTools;
393 
394  while (!reader.atEnd())
395  {
396  if (!reader.read(&matrix, &timestamp, &toolUid))
397  break;
398 
399  ToolPtr current = this->getTool(toolUid);
400  if (current)
401  {
402  (*current->getPositionHistory())[timestamp] = matrix;
403  }
404  else
405  {
406  missingTools << toolUid;
407  }
408  }
409 
410  missingTools.removeDuplicates();
411  missingTools.removeAll("");
412 
413  if (!missingTools.empty())
414  {
415  reportWarning(QString("Loaded position history, but some of the tools "
416  "are not present in the configuration:"
417  "\n \t%1").arg(missingTools.join("\n \t")));
418  }
419 
420  mLastLoadPositionHistory = getMilliSecondsSinceEpoch();
421 }
422 
423 //void TrackingImplService::setLoggingFolder(QString loggingFolder)
424 //{
425 // if (mLoggingFolder == loggingFolder)
426 // return;
427 
428 // for (unsigned i=0; i<mTrackingSystems.size(); ++i)
429 // mTrackingSystems[i]->setLoggingFolder(loggingFolder);
430 // mLoggingFolder = loggingFolder;
431 //}
432 
433 void TrackingImplService::globalConfigurationFileChangedSlot(QString key)
434 {
435  if (key.contains("TrackingPositionFilter"))
436  {
437  this->resetTrackingPositionFilters();
438  }
439 }
440 
441 void TrackingImplService::resetTrackingPositionFilters()
442 {
443  bool enabled = settings()->value("TrackingPositionFilter/enabled", false).toBool();
444  double cutoff = settings()->value("TrackingPositionFilter/cutoffFrequency", 0).toDouble();
445 
446  for (ToolMap::iterator iter=mTools.begin(); iter!=mTools.end(); ++iter)
447  {
449  if (enabled)
450  {
451  filter.reset(new TrackingPositionFilter());
452  if (cutoff>0.01)
453  filter->setCutOffFrequency(cutoff);
454  }
455  iter->second->resetTrackingPositionFilter(filter);
456  }
457 }
458 
459 void TrackingImplService::activeCheckSlot()
460 {
461  if (this->manualToolHasMostRecentTimestamp() && mManualTool->getVisible())
462  {
463  this->setActiveTool(this->getManualTool()->getUid());
464  return;
465  }
466 
467  bool use = settings()->value("Automation/autoSelectActiveTool").toBool();
468  if (!use)
469  return;
470 
471  //make a sorted vector of all visible tools
472  std::vector<ToolPtr> tools = this->getVisibleTools();
473  tools.push_back(mManualTool);
474 
475  if (!tools.empty())
476  {
477  //sort most important tool to the start of the vector:
478  sort(tools.begin(), tools.end(), toolTypeSort);
479  const QString uid = tools[0]->getUid();
480  this->setActiveTool(uid);
481  }
482 }
483 
484 bool TrackingImplService::manualToolHasMostRecentTimestamp()
485 {
486  // original comment (was wrapped in an ifplayblack):
487  // In static playback mode, tools does not turn invisible since
488  // time dont move. Here we check whether manual tool has a newer
489  // timestamp than the playback tools. If it has, make it active.
490  // This enables automatic change to manual tool if the user
491  // manipulates the manual tool in some way.
492 
493  double mts = this->getManualTool()->getTimestamp();
494 // std::cout << " manual tooltime " << mts << std::endl;
495 
496  double bestTime = 0;
497  for (ToolMap::iterator it = mTools.begin(); it != mTools.end(); ++it)
498  {
499 // std::cout << " tool " << it->first << " -- "<< it->second->getTimestamp() << std::endl;
500  if (it->second->hasType(Tool::TOOL_MANUAL))
501  continue;
502 // std::cout << " tool " << it->first << " : "<< it->second->getTimestamp() - mts << std::endl;
503  bestTime = std::max(bestTime, it->second->getTimestamp());
504  }
505 // double ahead = mts -bestTime;
506 // std::cout << " mts -bestTime " << " : "<< (mts -bestTime) << std::endl;
507 // std::cout << " mts > bestTime " << " : "<< bool(mts > bestTime) << std::endl;
508 
509  return (mts > bestTime);
510 }
511 
512 std::vector<ToolPtr> TrackingImplService::getVisibleTools()
513 {
514  std::vector<ToolPtr> retval;
515  for (ToolMap::iterator it = mTools.begin(); it != mTools.end(); ++it)
516  if (it->second->getVisible())
517  retval.push_back(it->second);
518  return retval;
519 }
520 
521 
522 
523 namespace
524 {
528 int getPriority(ToolPtr tool)
529 {
530  if (tool->hasType(Tool::TOOL_MANUAL)) // place this first, in case a tool has several attributes.
531  return 2;
532 
533  if (tool->hasType(Tool::TOOL_US_PROBE))
534  return 4;
535  if (tool->hasType(Tool::TOOL_POINTER))
536  return 3;
537  if (tool->hasType(Tool::TOOL_REFERENCE))
538  return 1;
539  return 0;
540 }
541 }
542 
549 bool toolTypeSort(const ToolPtr tool1, const ToolPtr tool2)
550 {
551  return getPriority(tool2) < getPriority(tool1);
552 }
553 
554 QString TrackingImplService::getLoggingFolder()
555 {
556  return mSession->getSubFolder("Logs/");
557 }
558 
559 void TrackingImplService::onSessionChanged()
560 {
561  QString loggingFolder = this->getLoggingFolder();
562 
563  for (unsigned i=0; i<mTrackingSystems.size(); ++i)
564  mTrackingSystems[i]->setLoggingFolder(loggingFolder);
565 }
566 
567 void TrackingImplService::onSessionCleared()
568 {
569  mManualTool->set_prMt(Transform3D::Identity());
570 }
571 
572 void TrackingImplService::onSessionLoad(QDomElement& node)
573 {
574  XMLNodeParser root(node);
575  QDomElement toolManagerNode = root.descend("managers/toolManager").node().toElement();
576  if (!toolManagerNode.isNull())
577  this->parseXml(toolManagerNode);
578 
579 }
580 
581 void TrackingImplService::onSessionSave(QDomElement& node)
582 {
583  XMLNodeAdder root(node);
584  QDomElement managerNode = root.descend("managers").node().toElement();
585  this->addXml(managerNode);
586 
587  this->savePositionHistory();
588 }
589 
590 void TrackingImplService::addXml(QDomNode& parentNode)
591 {
592  XMLNodeAdder parent(parentNode);
593  XMLNodeAdder base(parent.addElement("toolManager"));
594 
595  base.addTextToElement("toolTipOffset", qstring_cast(mToolTipOffset));
596  base.addTextToElement("manualTool", "\n" + qstring_cast(mManualTool->get_prMt()));
597 
598  //Tools
599  XMLNodeAdder toolsNode(base.addElement("tools"));
600  ToolMap tools = this->getTools();
601  ToolMap::iterator toolIt = tools.begin();
602  for (; toolIt != tools.end(); ++toolIt)
603  {
604  cxToolPtr tool = boost::dynamic_pointer_cast<ToolImpl>(toolIt->second);
605  if (tool)
606  {
607  toolsNode.addObjectToElement("tool", tool);
608  }
609  }
610 
611 }
612 
613 void TrackingImplService::parseXml(QDomNode& dataNode)
614 {
615  if (dataNode.isNull())
616  return;
617 
618  XMLNodeParser base(dataNode);
619 
620  QString manualToolText = dataNode.namedItem("manualTool").toElement().text();
621  mManualTool->set_prMt(Transform3D::fromString(manualToolText));
622 
623  mToolTipOffset = base.parseDoubleFromElementWithDefault("toolTipOffset", 0.0);
624  this->onTooltipOffset(mToolTipOffset);
625 
626  //Tools
627  ToolMap tools = this->getTools();
628  XMLNodeParser toolssNode(dataNode.namedItem("tools"));
629  std::vector<QDomElement> toolNodes = toolssNode.getDuplicateElements("tool");
630 
631  for (unsigned i=0; i<toolNodes.size(); ++i)
632  {
633  QDomElement toolNode = toolNodes[i];
634  QString tool_uid = toolNode.attribute("uid");
635  if (tools.find(tool_uid) != tools.end())
636  {
637  cxToolPtr tool = boost::dynamic_pointer_cast<ToolImpl>(tools.find(tool_uid)->second);
638  tool->parseXml(toolNode);
639  }
640  }
641 }
642 
644 {
645  return mManualTool;
646 }
647 
657 {
658  ToolPtr active = this->getActiveTool();
659 
660  // Turned off the check for valid probe fix #1038: No probe sector in 3D scene if no xml emtry for probe.
661  // This will work for digital interfaces where the probe sector definition comes from the interface, and not from the xml file.
662 // if (active && active->getProbe() && active->getProbe()->isValid())
663  if (active && active->getProbe())
664  return active;
665 
666  ToolMap tools = this->getTools();
667 
668  // look for visible probes
669  for (ToolMap::iterator iter = tools.begin(); iter != tools.end(); ++iter)
670  if (iter->second->getProbe() && iter->second->getProbe()->isValid() && iter->second->getVisible())
671  return iter->second;
672 
673  // pick the first probe, visible or not.
674  for (ToolMap::iterator iter = tools.begin(); iter != tools.end(); ++iter)
675  if (iter->second->getProbe() && iter->second->getProbe()->isValid())
676  return iter->second;
677 
678  return ToolPtr();
679 }
680 
681 //This may not work if more than one tracking system returns a configuration?
683 {
685  for (unsigned i=0; i<mTrackingSystems.size(); ++i)
686  {
687  TrackerConfigurationPtr config2 = mTrackingSystems[i]->getConfiguration();
688  if (config2)
689  {
690  config = config2;
691 // CX_LOG_DEBUG() << "getConfiguration config TrackingSystemSolution: " << config->getTrackingSystemImplementation();
692  }
693  }
694  return config;
695 }
696 
697 
698 } //namespace cx
int getPriority(DataPtr data)
QString qstring_cast(const T &val)
double parseDoubleFromElementWithDefault(QString name, double defaultValue)
Transform3D createTransformRotateY(const double angle)
virtual void runDummyTool(DummyToolPtr tool)
void isLoading(QDomElement &root)
emitted while loading a session. Xml storage is available, getRootFolder() is set to loaded value...
XMLNodeAdder descend(QString path)
virtual ToolPtr getFirstProbe()
Find a probe that can be connected to a rt source.
std::map< ToolPtr, TimedTransformMap > SessionToolHistoryMap
virtual ToolPtr getTool(const QString &uid)
get a specific tool
virtual void parseXml(QDomNode &dataNode)
Definition: cxToolImpl.h:51
QDomElement addElement(QString name)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< ToolImpl > cxToolPtr
Definition: cxToolImpl.h:71
Common functionality for Tool subclasses.
Definition: cxToolImpl.h:30
std::vector< QDomElement > getDuplicateElements(QString name)
double getMilliSecondsSinceEpoch()
Definition: cxTime.cpp:44
static SessionStorageServicePtr create(ctkPluginContext *pluginContext)
void toolTransformAndTimestamp(Transform3D matrix, double timestamp)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Definition: cxSettings.cpp:66
virtual Tool::State getState() const
virtual void setState(const Tool::State val)
virtual void setPlaybackMode(PlaybackTimePtr controller)
configured with basic info
Definition: cxTool.h:75
void sessionChanged()
emitted after change to a new session (new or loaded or cleared)
Reference tool.
Definition: cxTool.h:84
bool toolTypeSort(const ToolPtr tool1, const ToolPtr tool2)
function for sorting tools by type
boost::shared_ptr< class PlaybackTime > PlaybackTimePtr
Reader class for the position file.
virtual void setActiveTool(const QString &uid)
can be set to either a connected or configured tool
boost::shared_ptr< class DummyTool > DummyToolPtr
boost::shared_ptr< class TrackerConfiguration > TrackerConfigurationPtr
void activeToolChanged(const QString &uId)
void toolVisible(bool visible)
Tracking System Service.
void reportWarning(QString msg)
Definition: cxLogger.cpp:70
void tooltipOffset(double offset)
boost::shared_ptr< TimedTransformMap > TimedTransformMapPtr
Definition: cxTool.h:36
bool read(Transform3D *matrix, double *timestamp, int *toolIndex)
std::map< QString, ToolPtr > ToolMap
virtual ToolMap getTools()
get all configured and initialized tools
virtual TrackerConfigurationPtr getConfiguration()
QDomElement addTextToElement(QString name, QString text)
virtual ToolPtr getManualTool()
a mouse-controllable virtual tool that is available even when not tracking.
virtual void unInstallTrackingSystem(TrackingSystemServicePtr system)
XMLNodeParser descend(QString path)
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:85
not available
Definition: cxTool.h:74
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21
Writer class for the position file.
void cleared()
emitted when session is cleared, before isLoading is called
Helper class for listening to services being added, modified and removed.
std::map< QString, ToolPtr > ToolMap
virtual std::vector< TrackingSystemServicePtr > getTrackingSystems()
virtual ToolPtr getReferenceTool() const
get the tool that is used as a reference, if any
Interface towards a dummy tracking system.
void report(QString msg)
Definition: cxLogger.cpp:69
TrackingImplService(ctkPluginContext *context)
Adapter class for ManualTool.A ManualToolAdapter inherits from manual tool, but also contains a cx::T...
void write(Transform3D matrix, uint64_t timestamp, int toolIndex)
virtual ToolPtr getActiveTool()
get the tool that has higest priority when tracking
Transform3D createTransformRotateZ(const double angle)
virtual bool isPlaybackMode() const
emitting tracking data
Definition: cxTool.h:77
Interface towards a playback tracking system.Wraps another tracking system, enabling playback of the ...
boost::shared_ptr< class TrackingPositionFilter > TrackingPositionFilterPtr
Definition: cxTool.h:37
virtual SessionToolHistoryMap getSessionHistory(double startTime, double stopTime)
Ultrasond probe. The tool has a Probe subinterface with a sector and a video stream.
Definition: cxTool.h:87
virtual void installTrackingSystem(TrackingSystemServicePtr system)
void isSaving(QDomElement &root)
xml storage is available
Navigation pointer. Pointing functionality such as tool offset.
Definition: cxTool.h:86
#define M_PI
std::map< double, Transform3D > TimedTransformMap
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr
boost::shared_ptr< class TrackingSystemService > TrackingSystemServicePtr