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