CustusX  22.04-rc5
An IGT application
cxTrackingSystemBronchoscopyService.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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
33 
34 
35 #include "cxReporter.h"
36 #include "cxTime.h"
37 #include "cxPlaybackTime.h"
38 #include "cxBronchoscopyTool.h"
39 #include <QApplication>
40 #include "cxUtilHelpers.h"
41 #include "cxManualTool.h"
42 #include "cxTrackerConfiguration.h"
44 
45 
46 namespace cx
47 {
48 
50  mBase(trackingService->getTrackingSystems().back()),
51  mTrackingService(trackingService),
52  mProjectionCenterline(projectionCenterline),
53  mTool(tool)
54 {
55  connect(mBase.get(), &TrackingSystemService::stateChanged, this, &TrackingSystemBronchoscopyService::onStateChanged);
56  if (!mTool)
57  mTool = mTrackingService->getActiveTool(); // Use active tool if tool is not set
58  this->onStateChanged();
59 }
60 
62 {
63 }
64 
66 {
67  std::vector<TrackingSystemServicePtr> trackingSystems = mTrackingService->getTrackingSystems();
68  for (int i=0; i<trackingSystems.size(); i++)
69  if (trackingSystems[i]->getUid() == trackingSystemName)
70  {
71  mBase = trackingSystems[i];
72  return true;
73  }
74  return false;
75 }
76 
78 {
79  mTool = tool;
80 }
81 
82 void TrackingSystemBronchoscopyService::onStateChanged()
83 {
84  std::vector<ToolPtr> tools = mBase->getTools();
85  mTools.clear();
86  for (unsigned i=0; i<tools.size(); ++i)
87  {
88  if (tools[i] == mTool)
89  {
90  BronchoscopyToolPtr current(new BronchoscopyTool(tools[i], mProjectionCenterline));
91  mTools.push_back(current);
92  }
93  else
94  mTools.push_back(tools[i]);
95  }
96  emit stateChanged();
97 }
98 
100 {
101  return mBase->getReference();
102 }
103 
104 
106 {
107  return mTools;
108 }
109 
111 {
112  return mBase->getState();
113 }
114 
116 {
117  mBase->setState(val);
118 }
119 
121 {
122  mBase->setLoggingFolder(loggingFolder);
123 }
124 
126 {
127  return mBase->getConfiguration();
128 }
129 
130 
131 } // namespace cx
boost::shared_ptr< class TrackingService > TrackingServicePtr
ToolPtr getReference()
reference tool used by entire tracking service - NOTE: system fails if several TrackingSystemServices...
virtual void setState(const Tool::State val)
asynchronously request a state. Wait for signal stateChanged()
void stateChanged()
Reset time synchronization. Used for resetting time synchronization of incoming timestamps in OpenIGT...
boost::shared_ptr< class TrackerConfiguration > TrackerConfigurationPtr
TrackingSystemBronchoscopyService(TrackingServicePtr trackingService, BronchoscopePositionProjectionPtr projectionCenterline, ToolPtr tool=NULL)
A tool used during playback.
boost::shared_ptr< class BronchoscopePositionProjection > BronchoscopePositionProjectionPtr
boost::shared_ptr< class BronchoscopyTool > BronchoscopyToolPtr
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr