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