CustusX  22.04-rc5
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
boost::shared_ptr< ToolInternalStructure > ToolInternalStructurePtr
IgstkTrackerThread(ToolFileParser::TrackerInternalStructure trackerStructure, std::vector< ToolFileParser::ToolInternalStructurePtr > toolStructures, ToolFileParser::ToolInternalStructurePtr referenceToolStructure)
boost::shared_ptr< class IgstkTool > IgstkToolPtr
void initialize(bool on)
connects to the hardware. Threadsafe.
void requestTrack(bool on)
internal signal
void track(bool on)
tracking on or off. Threadsafe.
IgstkToolPtr getRefereceTool()
ThreadSafe.
void tracking(bool on)
void initialized(bool on)
system is initialized
Manager for IGSTK interface.The manager exists inside IgstkTrackerThread .
void requestInitialize(bool on)
internal signal
void configured(bool on)
std::map< QString, IgstkToolPtr > getTools()
ThreadSafe.
Namespace for all CustusX production code.