NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxIgstkTrackerThread.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 #include "cxIgstkTrackerThread.h"
13 
14 #include "cxIgstkTool.h"
15 #include "cxIgstkToolManager.h"
16 
17 
18 namespace cx
19 {
20 
22  std::vector<ToolFileParser::ToolInternalStructurePtr> toolStructures,
23  ToolFileParser::ToolInternalStructurePtr referenceToolStructure)
24 {
25  this->setObjectName("org.custusx.core.tracking.igstk"); // becomes the thread name
26  mInitTrackerStructure = trackerStructure;
27  mInitToolStructures = toolStructures;
28  mInitReferenceToolStructure = referenceToolStructure;
29 }
30 
32 {
33 }
34 
35 std::map<QString, IgstkToolPtr> IgstkTrackerThread::getTools()
36 {
37  return mManager->getTools();
38 }
39 
41 {
42  return mManager->getRefereceTool();
43 }
44 
46 {
47  emit requestInitialize(on);
48 }
49 
51 {
52  emit requestTrack(on);
53 }
54 
55 void IgstkTrackerThread::run()
56 {
57  this->configure();
58 
59  // run event loop
60  this->exec();
61 
62  this->deconfigure();
63 }
64 
65 void IgstkTrackerThread::configure()
66 {
67  mManager.reset(new IgstkToolManager(mInitTrackerStructure, mInitToolStructures, mInitReferenceToolStructure));
68  connect(mManager.get(), SIGNAL(initialized(bool)), this, SIGNAL(initialized(bool)));
69  connect(mManager.get(), SIGNAL(tracking(bool)), this, SIGNAL(tracking(bool)));
70  connect(mManager.get(), SIGNAL(error()), this, SIGNAL(error()));
71  connect(this, SIGNAL(requestInitialize(bool)), mManager.get(), SLOT(initializeSlot(bool)));
72  connect(this, SIGNAL(requestTrack(bool)), mManager.get(), SLOT(trackSlot(bool)));
73 
74  emit configured(true);
75 }
76 
77 void IgstkTrackerThread::deconfigure()
78 {
79  QObject::disconnect(mManager.get());
80  mManager.reset();
81 
82  emit configured(false);
83 }
84 
85 } //namespace cx
cx::IgstkTrackerThread::configured
void configured(bool on)
cx::IgstkTrackerThread::initialized
void initialized(bool on)
system is initialized
cxIgstkTrackerThread.h
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::IgstkToolPtr
boost::shared_ptr< class IgstkTool > IgstkToolPtr
Definition: cxOpenIGTLinkTool.h:35
cxIgstkTool.h
cx::IgstkTrackerThread::~IgstkTrackerThread
virtual ~IgstkTrackerThread()
Definition: cxIgstkTrackerThread.cpp:31
cxIgstkToolManager.h
cx::ToolFileParser::TrackerInternalStructure
Definition: cxToolFileParser.h:37
cx::IgstkTrackerThread::requestInitialize
void requestInitialize(bool on)
internal signal
cx::IgstkTrackerThread::getRefereceTool
IgstkToolPtr getRefereceTool()
ThreadSafe.
Definition: cxIgstkTrackerThread.cpp:40
cx::IgstkTrackerThread::IgstkTrackerThread
IgstkTrackerThread(ToolFileParser::TrackerInternalStructure trackerStructure, std::vector< ToolFileParser::ToolInternalStructurePtr > toolStructures, ToolFileParser::ToolInternalStructurePtr referenceToolStructure)
Definition: cxIgstkTrackerThread.cpp:21
cx::IgstkTrackerThread::error
void error()
cx::IgstkTrackerThread::initialize
void initialize(bool on)
connects to the hardware. Threadsafe.
Definition: cxIgstkTrackerThread.cpp:45
cx::IgstkTrackerThread::tracking
void tracking(bool on)
cx::IgstkTrackerThread::track
void track(bool on)
tracking on or off. Threadsafe.
Definition: cxIgstkTrackerThread.cpp:50
cx::IgstkTrackerThread::getTools
std::map< QString, IgstkToolPtr > getTools()
ThreadSafe.
Definition: cxIgstkTrackerThread.cpp:35
cx::IgstkTrackerThread::requestTrack
void requestTrack(bool on)
internal signal
cx::ToolFileParser::ToolInternalStructurePtr
boost::shared_ptr< ToolInternalStructure > ToolInternalStructurePtr
Definition: cxToolFileParser.h:99