CustusX  2023.01.05-dev+develop.0da12
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  if(!mActiveTool || !getTool(mActiveTool->getUid()))
241  this->setActiveTool(this->getManualTool()->getUid()); // this emits a signal: call after all other initialization
242 }
243 
244 void TrackingImplService::imbueManualToolWithRealProperties()
245 {
246  // debug: give the manual tool properties from the first non-manual tool. Nice for testing tools
247  if (!settings()->value("giveManualToolPhysicalProperties").toBool())
248  return;
249 
250  for (ToolMap::iterator iter = mTools.begin(); iter != mTools.end(); ++iter)
251  {
252  if (iter->second == mManualTool)
253  continue;
254  if (iter->second->hasType(Tool::TOOL_REFERENCE))
255  continue;
256  mManualTool->setBase(iter->second);
257  mManualTool->startEmittingContinuousPositions(100);
258 
259  report("Manual tool imbued with properties from " + iter->first);
260  break;
261  }
262 }
263 
264 void TrackingImplService::addToolsFrom(TrackingSystemServicePtr system)
265 {
266  std::vector<ToolPtr> tools = system->getTools();
267  for (unsigned i=0; i<tools.size(); ++i)
268  {
269  ToolPtr tool = tools[i];
270  mTools[tool->getUid()] = tool;
271  connect(tool.get(), SIGNAL(toolVisible(bool)), this, SLOT(activeCheckSlot()));
272  connect(tool.get(), &Tool::toolTransformAndTimestamp, this, &TrackingImplService::activeCheckSlot);
273  connect(tool.get(), &Tool::tooltipOffset, this, &TrackingImplService::onTooltipOffset);
274 
275  if (tool->hasType(Tool::TOOL_REFERENCE))
276  mReferenceTool = tool;
277  }
278 }
279 
280 void TrackingImplService::onTooltipOffset(double val)
281 {
282  mToolTipOffset = val;
283  for (ToolMap::iterator iter = mTools.begin(); iter != mTools.end(); ++iter)
284  {
285  iter->second->setTooltipOffset(val);
286  }
287 }
288 
290 {
291  SessionToolHistoryMap retval;
292 
293  ToolMap tools = this->getTools();
294  ToolMap::iterator it = tools.begin();
295  for (; it != tools.end(); ++it)
296  {
297  TimedTransformMap toolMap = it->second->getSessionHistory(startTime, stopTime);
298  if (toolMap.empty())
299  continue;
300  retval[it->second] = toolMap;
301  }
302  return retval;
303 }
304 
306 {
307  return mTools;
308 }
309 
311 {
312  if (uid == "active")
313  return this->getActiveTool();
314 
315  ToolPtr retval;
316  ToolMap::iterator it = mTools.find(uid);
317  if (it != mTools.end())
318  retval = it->second;
319 
320  return retval;
321 }
322 
324 {
325  return mActiveTool;
326 }
327 
328 void TrackingImplService::setActiveTool(const QString& uid)
329 {
330  if (mActiveTool && mActiveTool->getUid() == uid)
331  return;
332 
333  ToolPtr newTool;
334  newTool = this->getTool(uid);
335 
336  ToolPtr oldTool = mActiveTool;
337  mActiveTool = newTool; // set active before calling setters, which possibly can emit signal and cause cycles.
338 
339  // special case for manual tool
340  if (newTool && newTool->hasType(Tool::TOOL_MANUAL) && mManualTool)
341  {
342  if (oldTool && (oldTool!=mManualTool))
343  mManualTool->set_prMt(oldTool->get_prMt(), oldTool->getTimestamp() -1);
344  mManualTool->setVisible(true);
345  }
346  else
347  {
348  mManualTool->setVisible(false);
349  }
350 
351  emit activeToolChanged(uid);
352 }
353 
355 {
356  mActiveTool = mManualTool;
357  emit activeToolChanged(mActiveTool->getUid());
358 }
359 
361 {
362  return mReferenceTool;
363 }
364 
365 void TrackingImplService::savePositionHistory()
366 {
367  QString filename = this->getLoggingFolder() + "/toolpositions.snwpos";
368 
369  PositionStorageWriter writer(filename);
370 
371  ToolMap::iterator it = mTools.begin();
372  for (; it != mTools.end(); ++it)
373  {
374  ToolPtr current = it->second;
375  TimedTransformMapPtr data = current->getPositionHistory();
376 
377  if (!data)
378  continue;
379 
380  // save only data acquired after mLastLoadPositionHistory:
381  TimedTransformMap::iterator iter = data->lower_bound(mLastLoadPositionHistory);
382  for (; iter != data->end(); ++iter)
383  writer.write(iter->second, (iter->first), current->getUid());
384  }
385 
386  mLastLoadPositionHistory = getMilliSecondsSinceEpoch();
387 }
388 
389 void TrackingImplService::loadPositionHistory()
390 {
391  if (this->getState()==Tool::tsNONE)
392  return;
393  // save all position data acquired so far, in case of multiple calls.
394  this->savePositionHistory();
395 
396  QString filename = this->getLoggingFolder()+ "/toolpositions.snwpos";
397 
398  PositionStorageReader reader(filename);
399 
400  Transform3D matrix = Transform3D::Identity();
401  double timestamp;
402  QString toolUid;
403 
404  QStringList missingTools;
405 
406  while (!reader.atEnd())
407  {
408  if (!reader.read(&matrix, &timestamp, &toolUid))
409  break;
410 
411  ToolPtr current = this->getTool(toolUid);
412  if (current)
413  {
414  (*current->getPositionHistory())[timestamp] = matrix;
415  }
416  else
417  {
418  missingTools << toolUid;
419  }
420  }
421 
422  missingTools.removeDuplicates();
423  missingTools.removeAll("");
424 
425  if (!missingTools.empty())
426  {
427  reportWarning(QString("Loaded position history, but some of the tools "
428  "are not present in the configuration:"
429  "\n \t%1").arg(missingTools.join("\n \t")));
430  }
431 
432  mLastLoadPositionHistory = getMilliSecondsSinceEpoch();
433 }
434 
435 //void TrackingImplService::setLoggingFolder(QString loggingFolder)
436 //{
437 // if (mLoggingFolder == loggingFolder)
438 // return;
439 
440 // for (unsigned i=0; i<mTrackingSystems.size(); ++i)
441 // mTrackingSystems[i]->setLoggingFolder(loggingFolder);
442 // mLoggingFolder = loggingFolder;
443 //}
444 
445 void TrackingImplService::globalConfigurationFileChangedSlot(QString key)
446 {
447  if (key.contains("TrackingPositionFilter"))
448  {
449  this->resetTrackingPositionFilters();
450  }
451 }
452 
453 void TrackingImplService::resetTrackingPositionFilters()
454 {
455  bool enabled = settings()->value("TrackingPositionFilter/enabled", false).toBool();
456  double cutoff = settings()->value("TrackingPositionFilter/cutoffFrequency", 0).toDouble();
457 
458  for (ToolMap::iterator iter=mTools.begin(); iter!=mTools.end(); ++iter)
459  {
461  if (enabled)
462  {
463  filter.reset(new TrackingPositionFilter());
464  if (cutoff>0.01)
465  filter->setCutOffFrequency(cutoff);
466  }
467  iter->second->resetTrackingPositionFilter(filter);
468  }
469 }
470 
471 void TrackingImplService::activeCheckSlot()
472 {
473  if (this->manualToolHasMostRecentTimestamp() && mManualTool->getVisible())
474  {
475  this->setActiveTool(this->getManualTool()->getUid());
476  return;
477  }
478 
479  bool use = settings()->value("Automation/autoSelectActiveTool").toBool();
480  if (!use)
481  return;
482 
483  //make a sorted vector of all visible tools
484  std::vector<ToolPtr> tools = this->getVisibleTools();
485  tools.push_back(mManualTool);
486 
487  if (!tools.empty())
488  {
489  //sort most important tool to the start of the vector:
490  sort(tools.begin(), tools.end(), toolTypeSort);
491  const QString uid = tools[0]->getUid();
492  this->setActiveTool(uid);
493  }
494 }
495 
496 bool TrackingImplService::manualToolHasMostRecentTimestamp()
497 {
498  // original comment (was wrapped in an ifplayblack):
499  // In static playback mode, tools does not turn invisible since
500  // time dont move. Here we check whether manual tool has a newer
501  // timestamp than the playback tools. If it has, make it active.
502  // This enables automatic change to manual tool if the user
503  // manipulates the manual tool in some way.
504 
505  double mts = this->getManualTool()->getTimestamp();
506 // std::cout << " manual tooltime " << mts << std::endl;
507 
508  double bestTime = 0;
509  for (ToolMap::iterator it = mTools.begin(); it != mTools.end(); ++it)
510  {
511 // std::cout << " tool " << it->first << " -- "<< it->second->getTimestamp() << std::endl;
512  if (it->second->hasType(Tool::TOOL_MANUAL))
513  continue;
514 // std::cout << " tool " << it->first << " : "<< it->second->getTimestamp() - mts << std::endl;
515  bestTime = std::max(bestTime, it->second->getTimestamp());
516  }
517 // double ahead = mts -bestTime;
518 // std::cout << " mts -bestTime " << " : "<< (mts -bestTime) << std::endl;
519 // std::cout << " mts > bestTime " << " : "<< bool(mts > bestTime) << std::endl;
520 
521  return (mts > bestTime);
522 }
523 
524 std::vector<ToolPtr> TrackingImplService::getVisibleTools()
525 {
526  std::vector<ToolPtr> retval;
527  for (ToolMap::iterator it = mTools.begin(); it != mTools.end(); ++it)
528  if (it->second->getVisible())
529  retval.push_back(it->second);
530  return retval;
531 }
532 
533 
534 
535 namespace
536 {
540 int getPriority(ToolPtr tool)
541 {
542  if (tool->hasType(Tool::TOOL_MANUAL)) // place this first, in case a tool has several attributes.
543  return 2;
544 
545  if (tool->hasType(Tool::TOOL_US_PROBE))
546  return 4;
547  if (tool->hasType(Tool::TOOL_POINTER))
548  return 3;
549  if (tool->hasType(Tool::TOOL_REFERENCE))
550  return 1;
551  return 0;
552 }
553 }
554 
561 bool toolTypeSort(const ToolPtr tool1, const ToolPtr tool2)
562 {
563  return getPriority(tool2) < getPriority(tool1);
564 }
565 
566 QString TrackingImplService::getLoggingFolder()
567 {
568  return mSession->getSubFolder("Logs/");
569 }
570 
571 void TrackingImplService::onSessionChanged()
572 {
573  QString loggingFolder = this->getLoggingFolder();
574 
575  for (unsigned i=0; i<mTrackingSystems.size(); ++i)
576  mTrackingSystems[i]->setLoggingFolder(loggingFolder);
577 }
578 
579 void TrackingImplService::onSessionCleared()
580 {
581  mManualTool->set_prMt(Transform3D::Identity());
582 }
583 
584 void TrackingImplService::onSessionLoad(QDomElement& node)
585 {
586  XMLNodeParser root(node);
587  QDomElement toolManagerNode = root.descend("managers/toolManager").node().toElement();
588  if (!toolManagerNode.isNull())
589  this->parseXml(toolManagerNode);
590 
591 }
592 
593 void TrackingImplService::onSessionSave(QDomElement& node)
594 {
595  XMLNodeAdder root(node);
596  QDomElement managerNode = root.descend("managers").node().toElement();
597  this->addXml(managerNode);
598 
599  this->savePositionHistory();
600 }
601 
602 void TrackingImplService::addXml(QDomNode& parentNode)
603 {
604  XMLNodeAdder parent(parentNode);
605  XMLNodeAdder base(parent.addElement("toolManager"));
606 
607  base.addTextToElement("toolTipOffset", qstring_cast(mToolTipOffset));
608  base.addTextToElement("manualTool", "\n" + qstring_cast(mManualTool->get_prMt()));
609 
610  //Tools
611  XMLNodeAdder toolsNode(base.addElement("tools"));
612  ToolMap tools = this->getTools();
613  ToolMap::iterator toolIt = tools.begin();
614  for (; toolIt != tools.end(); ++toolIt)
615  {
616  cxToolPtr tool = boost::dynamic_pointer_cast<ToolImpl>(toolIt->second);
617  if (tool)
618  {
619  toolsNode.addObjectToElement("tool", tool);
620  }
621  }
622 
623 }
624 
625 void TrackingImplService::parseXml(QDomNode& dataNode)
626 {
627  if (dataNode.isNull())
628  return;
629 
630  XMLNodeParser base(dataNode);
631 
632  QString manualToolText = dataNode.namedItem("manualTool").toElement().text();
633  mManualTool->set_prMt(Transform3D::fromString(manualToolText));
634 
635  mToolTipOffset = base.parseDoubleFromElementWithDefault("toolTipOffset", 0.0);
636  this->onTooltipOffset(mToolTipOffset);
637 
638  //Tools
639  ToolMap tools = this->getTools();
640  XMLNodeParser toolssNode(dataNode.namedItem("tools"));
641  std::vector<QDomElement> toolNodes = toolssNode.getDuplicateElements("tool");
642 
643  for (unsigned i=0; i<toolNodes.size(); ++i)
644  {
645  QDomElement toolNode = toolNodes[i];
646  QString tool_uid = toolNode.attribute("uid");
647  if (tools.find(tool_uid) != tools.end())
648  {
649  cxToolPtr tool = boost::dynamic_pointer_cast<ToolImpl>(tools.find(tool_uid)->second);
650  tool->parseXml(toolNode);
651  }
652  }
653 }
654 
656 {
657  return mManualTool;
658 }
659 
669 {
670  ToolPtr active = this->getActiveTool();
671 
672  // Turned off the check for valid probe fix #1038: No probe sector in 3D scene if no xml emtry for probe.
673  // This will work for digital interfaces where the probe sector definition comes from the interface, and not from the xml file.
674 // if (active && active->getProbe() && active->getProbe()->isValid())
675  if (active && active->getProbe())
676  return active;
677 
678  ToolMap tools = this->getTools();
679 
680  // look for visible probes
681  for (ToolMap::iterator iter = tools.begin(); iter != tools.end(); ++iter)
682  if (iter->second->getProbe() && iter->second->getProbe()->isValid() && iter->second->getVisible())
683  return iter->second;
684 
685  // pick the first probe, visible or not.
686  for (ToolMap::iterator iter = tools.begin(); iter != tools.end(); ++iter)
687  if (iter->second->getProbe() && iter->second->getProbe()->isValid())
688  return iter->second;
689 
690  return ToolPtr();
691 }
692 
693 std::vector<TrackerConfigurationPtr> TrackingImplService::getConfigurations()
694 {
695  std::vector<TrackerConfigurationPtr> retval;
696  bool gotConfig = false;
697  for (unsigned i=0; i<mTrackingSystems.size(); ++i)
698  {
699  TrackerConfigurationPtr config = mTrackingSystems[i]->getConfiguration();
700  if (config)
701  {
702  retval.push_back(config);
703  //CX_LOG_DEBUG() << "getConfiguration config TrackingSystemSolution: " << config->getTrackingSystemImplementation();
704  gotConfig = true;
705  }
706  }
707  if(!gotConfig)
708  retval.push_back(TrackerConfigurationPtr());
709 
710  return retval;
711 }
712 
713 TrackerConfigurationPtr TrackingImplService::getConfiguration(QString trackingSystemImplementation)
714 {
715  std::vector<TrackerConfigurationPtr> configs = this->getConfigurations();
716  for(unsigned i = 0; i < configs.size(); ++i)
717  {
718  if(configs[i]->getTrackingSystemImplementation() == trackingSystemImplementation)
719  return configs[i];
720  }
721  return TrackerConfigurationPtr();
722 }
723 
725 {
726  TrackerConfigurationPtr retval = this->getConfiguration(mTrackingSystemImplementation);
727  if(!retval)
728  {
729  //Always try to return a tool configuration
730  std::vector<TrackerConfigurationPtr> configs = this->getConfigurations();
731  if(configs.size() > 0)
732  retval = configs.at(0);
733  }
734  return retval;
735 }
736 void TrackingImplService::setCurrentTrackingSystemImplementation(QString trackingSystemImplementation)
737 {
738  //CX_LOG_DEBUG() << "setCurrentTrackingSystemImplementation: " << trackingSystemImplementation;
739  mTrackingSystemImplementation = trackingSystemImplementation;
740 }
741 
743 {
744  return mTrackingSystemImplementation;
745 }
746 
748 {
749  for (unsigned i=0; i<mTrackingSystems.size(); ++i)
750  {
751  mTrackingSystems[i]->resetTimeSynchronization();
752  }
753 }
754 
755 } //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