NorMIT-nav  22.09
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  this->onStateChanged();
73  return true;
74  }
75  return false;
76 }
77 
79 {
80  mTool = tool;
81 }
82 
83 void TrackingSystemBronchoscopyService::onStateChanged()
84 {
85  std::vector<ToolPtr> tools = mBase->getTools();
86  mTools.clear();
87  for (unsigned i=0; i<tools.size(); ++i)
88  {
89  if (tools[i] == mTool)
90  {
91  BronchoscopyToolPtr current(new BronchoscopyTool(tools[i], mProjectionCenterline));
92  mTools.push_back(current);
93  }
94  else
95  mTools.push_back(tools[i]);
96  }
97  emit stateChanged();
98 }
99 
101 {
102  return mBase->getReference();
103 }
104 
105 
107 {
108  return mTools;
109 }
110 
112 {
113  return mBase->getState();
114 }
115 
117 {
118  mBase->setState(val);
119 }
120 
122 {
123  mBase->setLoggingFolder(loggingFolder);
124 }
125 
127 {
128  return mBase->getConfiguration();
129 }
130 
131 
132 } // namespace cx
cx::TrackingSystemBronchoscopyService::getConfiguration
virtual TrackerConfigurationPtr getConfiguration()
Definition: cxTrackingSystemBronchoscopyService.cpp:126
cxPlaybackTime.h
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::BronchoscopyToolPtr
boost::shared_ptr< class BronchoscopyTool > BronchoscopyToolPtr
Definition: cxBronchoscopyTool.h:43
cx::TrackerConfigurationPtr
boost::shared_ptr< class TrackerConfiguration > TrackerConfigurationPtr
Definition: cxTrackerConfiguration.h:24
cxUtilHelpers.h
cxReporter.h
cxManualTool.h
cx::TrackingSystemBronchoscopyService::getTools
virtual std::vector< ToolPtr > getTools()
Definition: cxTrackingSystemBronchoscopyService.cpp:106
cxBronchoscopePositionProjection.h
cx::TrackingSystemService::stateChanged
void stateChanged()
Reset time synchronization. Used for resetting time synchronization of incoming timestamps in OpenIGT...
cx::TrackingServicePtr
boost::shared_ptr< class TrackingService > TrackingServicePtr
Definition: cxToolFilterWidget.h:27
cx::TrackingSystemBronchoscopyService::TrackingSystemBronchoscopyService
TrackingSystemBronchoscopyService(TrackingServicePtr trackingService, BronchoscopePositionProjectionPtr projectionCenterline, ToolPtr tool=NULL)
Definition: cxTrackingSystemBronchoscopyService.cpp:49
cx::TrackingSystemBronchoscopyService::setState
virtual void setState(const Tool::State val)
asynchronously request a state. Wait for signal stateChanged()
Definition: cxTrackingSystemBronchoscopyService.cpp:116
cx::TrackingSystemBronchoscopyService::setLoggingFolder
virtual void setLoggingFolder(QString loggingFolder)
Definition: cxTrackingSystemBronchoscopyService.cpp:121
cx::Tool::State
State
Definition: cxTool.h:72
cx::TrackingSystemBronchoscopyService::getUid
virtual QString getUid() const
Definition: cxTrackingSystemBronchoscopyService.h:69
cx::TrackingSystemBronchoscopyService::~TrackingSystemBronchoscopyService
virtual ~TrackingSystemBronchoscopyService()
Definition: cxTrackingSystemBronchoscopyService.cpp:61
cx::BronchoscopePositionProjectionPtr
boost::shared_ptr< class BronchoscopePositionProjection > BronchoscopePositionProjectionPtr
Definition: cxBronchoscopePositionProjection.h:13
cxTime.h
cx::BronchoscopyTool
A tool used during playback.
Definition: cxBronchoscopyTool.h:54
cx::TrackingSystemBronchoscopyService::setTool
void setTool(ToolPtr tool)
Definition: cxTrackingSystemBronchoscopyService.cpp:78
cxBronchoscopyTool.h
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cxTrackerConfiguration.h
cx::TrackingSystemBronchoscopyService::setTrackingSystem
bool setTrackingSystem(QString trackingSystemName)
Definition: cxTrackingSystemBronchoscopyService.cpp:65
cx::TrackingSystemBronchoscopyService::getReference
ToolPtr getReference()
reference tool used by entire tracking service - NOTE: system fails if several TrackingSystemServices...
Definition: cxTrackingSystemBronchoscopyService.cpp:100
cxTrackingSystemBronchoscopyService.h
cx::TrackingSystemBronchoscopyService::getState
virtual Tool::State getState() const
Definition: cxTrackingSystemBronchoscopyService.cpp:111