NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxBronchoscopyTool.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 =========================================================================*/
32 
33 #include "cxBronchoscopyTool.h"
34 #include "cxTypeConversions.h"
36 #include "cxDoubleProperty.h"
37 #include "cxLogger.h"
38 
39 namespace cx
40 {
41 
43  ToolImpl(base->getUid(), "Bronchoscopy Navigation "+base->getName()),
44  mBase(base),
45  mProjectionCenterline(projectionCenterline)
46 {
47  connect(mBase.get(), &Tool::toolProbeSector, this, &Tool::toolProbeSector);
48  connect(mBase.get(), &Tool::tooltipOffset, this, &Tool::tooltipOffset);
49  connect(mBase.get(), &Tool::toolTransformAndTimestamp, this, &BronchoscopyTool::onToolTransformAndTimestamp);
50  connect(mBase.get(), &Tool::toolVisible, this, &Tool::toolVisible);
51  connect(mBase.get(), &Tool::tooltipOffset, this, &Tool::tooltipOffset);
52  connect(mBase.get(), &Tool::tps, this, &Tool::tps);
53 }
54 
56 {
57 }
58 
59 
60 std::set<Tool::Type> BronchoscopyTool::getTypes() const
61 {
62  return mBase->getTypes();
63 }
64 
65 void BronchoscopyTool::onToolTransformAndTimestamp(Transform3D prMt, double timestamp)
66 {
67  double maxDistanceToCenterline = mProjectionCenterline->getMaxDistanceToCenterlineValue();
68  double maxSearchDistance = mProjectionCenterline->getMaxSearchDistanceValue();
69 
70  if (mProjectionCenterline->isAdvancedCenterlineProjectionSelected())
71  m_prMt = mProjectionCenterline->findProjectedPoint(prMt, maxDistanceToCenterline, maxSearchDistance);
72  else
73  m_prMt = mProjectionCenterline->findClosestPointInBranches(prMt,maxDistanceToCenterline);
74 
75  emit toolTransformAndTimestamp(m_prMt, timestamp);
76 }
77 
79 {
80  return mBase->getGraphicsPolyData();
81 }
82 
84 {
85  return m_prMt;
86 }
87 
89 {
90  return mBase->getVisible();
91 }
92 
93 QString BronchoscopyTool::getUid() const
94 {
95  return mUid;
96 }
97 
99 {
100  return mName;
101 }
102 
104 {
105  return mBase->isCalibrated();
106 }
107 
109 {
110  return mBase->getTimestamp();
111 }
112 
113 // Just use the tool tip offset from the tool manager
115 {
116  return mBase->getTooltipOffset();
117 }
118 
119 // Just use the tool tip offset from the tool manager
121 {
122  mBase->setTooltipOffset(val);
123 }
124 
126 {
127  return mBase->getCalibration_sMt();
128 }
129 
130 std::map<QString, Vector3D> BronchoscopyTool::getReferencePoints() const
131 {
132  return mBase->getReferencePoints();
133 }
134 
136 {
137  return mBase->isInitialized();
138 }
139 
140 void BronchoscopyTool::set_prMt(const Transform3D& prMt, double timestamp)
141 {
142  mBase->set_prMt(prMt, timestamp);
143 
144 }
145 
147 {
148  mBase->setVisible(vis);
149 }
150 
151 
152 } /* namespace cx */
cx::BronchoscopyTool::BronchoscopyTool
BronchoscopyTool(ToolPtr base, BronchoscopePositionProjectionPtr projectionCenterline)
Definition: cxBronchoscopyTool.cpp:42
cx::BronchoscopyTool::getVisible
virtual bool getVisible() const
Definition: cxBronchoscopyTool.cpp:88
cxLogger.h
cx::BronchoscopyTool::getTypes
virtual std::set< Type > getTypes() const
Definition: cxBronchoscopyTool.cpp:60
cx::Tool::toolTransformAndTimestamp
void toolTransformAndTimestamp(Transform3D matrix, double timestamp)
cx::Tool::toolVisible
void toolVisible(bool visible)
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::Tool::tps
void tps(int)
cxDoubleProperty.h
cx::BronchoscopyTool::isCalibrated
virtual bool isCalibrated() const
a tool may not be calibrated, then no tracking is allowed
Definition: cxBronchoscopyTool.cpp:103
cx::BronchoscopyTool::getReferencePoints
virtual std::map< QString, Vector3D > getReferencePoints() const
Definition: cxBronchoscopyTool.cpp:130
cx::BronchoscopyTool::setVisible
virtual void setVisible(bool vis)
if available for this type, set visibility
Definition: cxBronchoscopyTool.cpp:146
cx::BronchoscopyTool::getTooltipOffset
virtual double getTooltipOffset() const
Definition: cxBronchoscopyTool.cpp:114
cx::BronchoscopyTool::set_prMt
virtual void set_prMt(const Transform3D &prMt, double timestamp)
if available for this type, set pos, ts<0 means use current time
Definition: cxBronchoscopyTool.cpp:140
cx::BronchoscopyTool::isInitialized
virtual bool isInitialized() const
Definition: cxBronchoscopyTool.cpp:135
cxBronchoscopePositionProjection.h
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cx::Tool::mUid
QString mUid
Definition: cxTool.h:149
cxTypeConversions.h
cx::Tool::toolProbeSector
void toolProbeSector()
cx::BronchoscopyTool::get_prMt
virtual Transform3D get_prMt() const
Definition: cxBronchoscopyTool.cpp:83
cx::vtkPolyDataPtr
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
Definition: cxCenterlineRegistration.h:42
cx::Tool::tooltipOffset
void tooltipOffset(double offset)
cx::BronchoscopyTool::getGraphicsPolyData
virtual vtkPolyDataPtr getGraphicsPolyData() const
get geometric 3D description
Definition: cxBronchoscopyTool.cpp:78
cx::BronchoscopyTool::getUid
virtual QString getUid() const
Definition: cxBronchoscopyTool.cpp:93
cx::BronchoscopePositionProjectionPtr
boost::shared_ptr< class BronchoscopePositionProjection > BronchoscopePositionProjectionPtr
Definition: cxBronchoscopePositionProjection.h:14
cx::BronchoscopyTool::setTooltipOffset
virtual void setTooltipOffset(double val)
Definition: cxBronchoscopyTool.cpp:120
cxBronchoscopyTool.h
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cx::ToolImpl
Common functionality for Tool subclasses.
Definition: cxToolImpl.h:30
cx::BronchoscopyTool::getTimestamp
virtual double getTimestamp() const
latest valid timestamp for the position matrix. 0 means indeterminate (for f.ex. manual tools)
Definition: cxBronchoscopyTool.cpp:108
cx::Tool::mName
QString mName
Definition: cxTool.h:150
cx::BronchoscopyTool::~BronchoscopyTool
virtual ~BronchoscopyTool()
Definition: cxBronchoscopyTool.cpp:55
cx::BronchoscopyTool::getName
virtual QString getName() const
Definition: cxBronchoscopyTool.cpp:98
cx::BronchoscopyTool::getCalibration_sMt
virtual Transform3D getCalibration_sMt() const
get the calibration transform from tool space to sensor space (where the spheres or similar live)
Definition: cxBronchoscopyTool.cpp:125