NorMIT-nav  22.09
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 {
215  this->installTrackingSystem(TrackingSystemServicePtr(service, null_deleter()));
216 }
217 
218 void TrackingImplService::onTrackingSystemRemoved(TrackingSystemService* service)
219 {
220  this->unInstallTrackingSystem(TrackingSystemServicePtr(service, null_deleter()));
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
cx::SessionStorageServiceProxy::create
static SessionStorageServicePtr create(ctkPluginContext *pluginContext)
Definition: cxSessionStorageServiceProxy.cpp:19
cx::TrackingImplService::setCurrentTrackingSystemImplementation
virtual void setCurrentTrackingSystemImplementation(QString trackingSystemImplementation)
Definition: cxTrackingImplService.cpp:736
cxLogger.h
cx::ManualToolAdapter
Adapter class for ManualTool.
Definition: cxManualToolAdapter.h:34
cx::TrackingImplService::installTrackingSystem
virtual void installTrackingSystem(TrackingSystemServicePtr system)
Definition: cxTrackingImplService.cpp:138
qstring_cast
QString qstring_cast(const T &val)
Definition: cxTypeConversions.h:46
cx::createTransformRotateZ
Transform3D createTransformRotateZ(const double angle)
Definition: cxTransform3D.cpp:185
cxPositionStorageFile.h
cxPlaybackTime.h
cx::Settings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Definition: cxSettings.cpp:66
cxTrackingImplService.h
cx::Tool::toolTransformAndTimestamp
void toolTransformAndTimestamp(Transform3D matrix, double timestamp)
cx::TrackingImplService::isPlaybackMode
virtual bool isPlaybackMode() const
Definition: cxTrackingImplService.cpp:123
cx::Tool::toolVisible
void toolVisible(bool visible)
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::Tool::TOOL_MANUAL
@ TOOL_MANUAL
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:85
cx::TrackingImplService::resetTimeSynchronization
virtual void resetTimeSynchronization()
Reset time synchronization. Used for resetting time synchronization of incoming timestamps in OpenIGT...
Definition: cxTrackingImplService.cpp:747
cx::getMilliSecondsSinceEpoch
double getMilliSecondsSinceEpoch()
Definition: cxTime.cpp:44
cx::ServiceTrackerListener
Helper class for listening to services being added, modified and removed.
Definition: cxServiceTrackerListener.h:53
cx::TrackerConfigurationPtr
boost::shared_ptr< class TrackerConfiguration > TrackerConfigurationPtr
Definition: cxTrackerConfiguration.h:24
cx::TrackingImplService::getState
virtual Tool::State getState() const
Definition: cxTrackingImplService.cpp:188
cx::report
void report(QString msg)
Definition: cxLogger.cpp:69
cx::TrackingImplService::getTool
virtual ToolPtr getTool(const QString &uid)
get a specific tool
Definition: cxTrackingImplService.cpp:310
cxDummyTool.h
cxTrackingSystemPlaybackService.h
cxTrackerConfigurationImpl.h
cx::Tool::TOOL_POINTER
@ TOOL_POINTER
Navigation pointer. Pointing functionality such as tool offset.
Definition: cxTool.h:86
cxUtilHelpers.h
cx::PositionStorageWriter
Writer class for the position file.
Definition: cxPositionStorageFile.h:89
cx::TrackingImplService::getConfiguration
virtual TrackerConfigurationPtr getConfiguration()
Definition: cxTrackingImplService.cpp:724
cx::TrackingImplService::unInstallTrackingSystem
virtual void unInstallTrackingSystem(TrackingSystemServicePtr system)
Definition: cxTrackingImplService.cpp:147
cx::TrackingSystemPlaybackService
Interface towards a playback tracking system.
Definition: cxTrackingSystemPlaybackService.h:35
cx::TrackingPositionFilterPtr
boost::shared_ptr< class TrackingPositionFilter > TrackingPositionFilterPtr
Definition: cxTool.h:37
cx::PlaybackTimePtr
boost::shared_ptr< class PlaybackTime > PlaybackTimePtr
Definition: cxTrackingSystemBronchoscopyService.h:42
cx::TrackingSystemDummyService
Interface towards a dummy tracking system.
Definition: cxTrackingSystemDummyService.h:27
cx::SessionToolHistoryMap
std::map< ToolPtr, TimedTransformMap > SessionToolHistoryMap
Definition: cxTrackingService.h:31
cx::TrackingSystemService::stateChanged
void stateChanged()
Reset time synchronization. Used for resetting time synchronization of incoming timestamps in OpenIGT...
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cxNullDeleter.h
cxSessionStorageServiceProxy.h
cxXMLNodeWrapper.h
cx::TimedTransformMap
std::map< double, Transform3D > TimedTransformMap
Definition: cxRecordSession.h:36
cx::TrackingSystemServicePtr
boost::shared_ptr< class TrackingSystemService > TrackingSystemServicePtr
Definition: cxTrackingImplService.h:36
cxTypeConversions.h
cx::TrackingSystemService::updateTrackingSystemImplementation
void updateTrackingSystemImplementation(QString trackingSystemImplementation)
cx::Tool::TOOL_US_PROBE
@ TOOL_US_PROBE
Ultrasond probe. The tool has a Probe subinterface with a sector and a video stream.
Definition: cxTool.h:87
cx::Tool::tsNONE
@ tsNONE
not available
Definition: cxTool.h:74
cx::Tool::State
State
Definition: cxTool.h:72
cx::TrackingService::stateChanged
void stateChanged()
cx::TrackingImplService::setState
virtual void setState(const Tool::State val)
Definition: cxTrackingImplService.cpp:196
cx::TrackingService::activeToolChanged
void activeToolChanged(const QString &uId)
cx::SessionStorageService::isSaving
void isSaving(QDomElement &root)
xml storage is available
cx::TrackingImplService::setPlaybackMode
virtual void setPlaybackMode(PlaybackTimePtr controller)
Definition: cxTrackingImplService.cpp:97
cxSettings.h
cx::TimedTransformMapPtr
boost::shared_ptr< TimedTransformMap > TimedTransformMapPtr
Definition: cxTool.h:36
cx::TrackingImplService::setActiveTool
virtual void setActiveTool(const QString &uid)
can be set to either a connected or configured tool
Definition: cxTrackingImplService.cpp:328
cxRegistrationTransform.h
cx::Tool::tsCONFIGURED
@ tsCONFIGURED
configured with basic info
Definition: cxTool.h:75
cxTrackingSystemDummyService.h
cx::TrackingImplService::getConfigurations
virtual std::vector< TrackerConfigurationPtr > getConfigurations()
Definition: cxTrackingImplService.cpp:693
cx::Tool::tooltipOffset
void tooltipOffset(double offset)
cxToolImpl.h
cx::cxToolPtr
boost::shared_ptr< ToolImpl > cxToolPtr
Definition: cxToolImpl.h:72
M_PI
#define M_PI
Definition: cxReconstructParams.cpp:25
cxTime.h
cx::TrackingImplService::getActiveTool
virtual ToolPtr getActiveTool()
get the tool that has higest priority when tracking
Definition: cxTrackingImplService.cpp:323
cx::TrackingImplService::getSessionHistory
virtual SessionToolHistoryMap getSessionHistory(double startTime, double stopTime)
Definition: cxTrackingImplService.cpp:289
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cx::TrackingImplService::~TrackingImplService
virtual ~TrackingImplService()
Definition: cxTrackingImplService.cpp:73
cx::TrackingImplService::isNull
bool isNull()
Definition: cxTrackingImplService.cpp:80
cx::TrackingImplService::getTools
virtual ToolMap getTools()
get all configured and initialized tools
Definition: cxTrackingImplService.cpp:305
cx::TrackingImplService::runDummyTool
virtual void runDummyTool(DummyToolPtr tool)
Definition: cxTrackingImplService.cpp:128
cx::TrackingImplService::TrackingImplService
TrackingImplService(ctkPluginContext *context)
Definition: cxTrackingImplService.cpp:53
cx::createTransformRotateY
Transform3D createTransformRotateY(const double angle)
Definition: cxTransform3D.cpp:178
cxToolConfigurationParser.h
cx::SessionStorageService::isLoading
void isLoading(QDomElement &root)
emitted while loading a session. Xml storage is available, getRootFolder() is set to loaded value.
cx::TrackingImplService::getReferenceTool
virtual ToolPtr getReferenceTool() const
get the tool that is used as a reference, if any
Definition: cxTrackingImplService.cpp:360
cx::TrackingImplService::getFirstProbe
virtual ToolPtr getFirstProbe()
Find a probe that can be connected to a rt source.
Definition: cxTrackingImplService.cpp:668
cxTrackingPositionFilter.h
cx::TrackingImplService::getManualTool
virtual ToolPtr getManualTool()
a mouse-controllable virtual tool that is available even when not tracking.
Definition: cxTrackingImplService.cpp:655
cx::TrackingSystemPlaybackService::onActiveToolChanged
void onActiveToolChanged(const QString &uId)
Definition: cxTrackingSystemPlaybackService.cpp:175
cx::Tool::tsTRACKING
@ tsTRACKING
emitting tracking data
Definition: cxTool.h:77
cx::TrackingImplService::getTrackingSystems
virtual std::vector< TrackingSystemServicePtr > getTrackingSystems()
Definition: cxTrackingImplService.cpp:164
cx::DummyToolPtr
boost::shared_ptr< class DummyTool > DummyToolPtr
Definition: cxForwardDeclarations.h:44
cx::TrackingImplService::getCurrentTrackingSystemImplementation
virtual QString getCurrentTrackingSystemImplementation()
Definition: cxTrackingImplService.cpp:742
cx::SessionStorageService::sessionChanged
void sessionChanged()
emitted after change to a new session (new or loaded or cleared)
cxManualToolAdapter.h
cx::getPriority
int getPriority(DataPtr data)
Definition: cxViewGroupData.cpp:262
cx::reportWarning
void reportWarning(QString msg)
Definition: cxLogger.cpp:70
cx::SessionStorageService::cleared
void cleared()
emitted when session is cleared, before isLoading is called
cx::settings
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21
cx::TrackingService::ToolMap
std::map< QString, ToolPtr > ToolMap
Definition: cxTrackingService.h:54
cx::toolTypeSort
bool toolTypeSort(const ToolPtr tool1, const ToolPtr tool2)
function for sorting tools by type
Definition: cxTrackingImplService.cpp:561
cxPlaybackTool.h
cx::TrackingImplService::clearActiveTool
virtual void clearActiveTool()
Deselect active tool.
Definition: cxTrackingImplService.cpp:354
cx::Tool::TOOL_REFERENCE
@ TOOL_REFERENCE
Reference tool.
Definition: cxTool.h:84