Fraxinus  22.09
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 */
virtual double getTooltipOffset() const
get a virtual offset extending from the tool tip.
virtual bool isCalibrated() const
a tool may not be calibrated, then no tracking is allowed
virtual double getTimestamp() const
latest valid timestamp for the position matrix. 0 means indeterminate (for f.ex. manual tools) ...
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Common functionality for Tool subclasses.
Definition: cxToolImpl.h:30
virtual void setTooltipOffset(double val)
set a virtual offset extending from the tool tip.
void toolProbeSector()
virtual bool getVisible() const
void toolTransformAndTimestamp(Transform3D matrix, double timestamp)
virtual std::map< QString, Vector3D > getReferencePoints() const
Get the optional reference points from this tool.
virtual QString getUid() const
QString mUid
Definition: cxTool.h:149
BronchoscopyTool(ToolPtr base, BronchoscopePositionProjectionPtr projectionCenterline)
virtual QString getName() const
void toolVisible(bool visible)
virtual void set_prMt(const Transform3D &prMt, double timestamp)
if available for this type, set pos, ts<0 means use current time
QString mName
Definition: cxTool.h:150
void tooltipOffset(double offset)
virtual vtkPolyDataPtr getGraphicsPolyData() const
get geometric 3D description
virtual bool isInitialized() const
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
void tps(int)
virtual void setVisible(bool vis)
if available for this type, set visibility
virtual std::set< Type > getTypes() const
virtual Transform3D getCalibration_sMt() const
get the calibration transform from tool space to sensor space (where the spheres or similar live) ...
boost::shared_ptr< class BronchoscopePositionProjection > BronchoscopePositionProjectionPtr
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr
virtual Transform3D get_prMt() const