CustusX  15.8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxManualToolAdapter.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 "cxManualToolAdapter.h"
34 
35 namespace cx
36 {
37 
39  ManualTool(uid)
40 {
41  ToolPtr initial(new ManualTool(uid + "base"));
42  this->setBase(initial);
43 // mBase.reset(new ManualTool(uid + "base"));
44 // connect(mBase.get(), SIGNAL(toolProbeSector()), this, SIGNAL(toolProbeSector()));
45 }
46 
48  ManualTool(mBase->getUid() + "_manual"), mBase(base)
49 {
50 }
51 
53 {
54 }
55 
57 {
58  if (mBase)
59  {
60  disconnect(mBase.get(), &Tool::toolTransformAndTimestamp, this, &Tool::toolTransformAndTimestamp);
61  disconnect(mBase.get(), &Tool::toolVisible, this, &Tool::toolVisible);
62  disconnect(mBase.get(), &Tool::tooltipOffset, this, &Tool::tooltipOffset);
63  disconnect(mBase.get(), &Tool::toolProbeSector, this, &Tool::toolProbeSector);
64  disconnect(mBase.get(), &Tool::tps, this, &Tool::tps);
65  }
66 
67  mBase = base;
68 
69  if (mBase)
70  {
72  connect(mBase.get(), &Tool::toolVisible, this, &Tool::toolVisible);
73  connect(mBase.get(), &Tool::tooltipOffset, this, &Tool::tooltipOffset);
74  connect(mBase.get(), &Tool::toolProbeSector, this, &Tool::toolProbeSector);
75  connect(mBase.get(), &Tool::tps, this, &Tool::tps);
76  }
77 
78  emit toolVisible(this->getVisible());
79  emit toolTransformAndTimestamp(this->get_prMt(), this->getTimestamp());
80  emit tooltipOffset(this->getTooltipOffset());
81  emit toolProbeSector();
82  emit tps(0);
83 }
84 
86 {
87  return mBase->getGraphicsPolyData();
88 }
89 
91 {
92  return mBase->isCalibrated();
93 }
94 
96 {
97  return mBase->getProbe();
98 }
99 
101 {
102  return mBase->getCalibration_sMt();
103 }
104 
105 std::map<int, Vector3D> ManualToolAdapter::getReferencePoints() const
106 {
107  return mBase->getReferencePoints();
108 }
109 
111 {
112  return mBase->getTooltipOffset();
113 }
114 
116 {
117  mBase->setTooltipOffset(val);
118 }
119 
120 std::set<Tool::Type> ManualToolAdapter::getTypes() const
121 {
122  std::set<Tool::Type> retval = mBase->getTypes();
123  retval.insert(Tool::TOOL_MANUAL);
124  return retval;
125 }
126 
127 }
virtual bool getVisible() const
virtual double getTooltipOffset() const
get a virtual offset extending from the tool tip.
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.
void toolProbeSector()
virtual void setTooltipOffset(double val)
set a virtual offset extending from the tool tip.
void toolTransformAndTimestamp(Transform3D matrix, double timestamp)
virtual Transform3D getCalibration_sMt() const
get the calibration transform from tool space to sensor space (where the spheres or similar live) ...
virtual std::map< int, Vector3D > getReferencePoints() const
Get the optional reference points from this tool.
virtual bool isCalibrated() const
a tool may not be calibrated, then no tracking i allowed
void setBase(ToolPtr base)
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
Definition: cxProbeSector.h:47
ManualTool(const QString &uid, const QString &name="")
A manual tool that is unconnected to any hardware.
Definition: cxManualTool.h:57
boost::shared_ptr< Probe > ProbePtr
Definition: cxProbe.h:93
virtual vtkPolyDataPtr getGraphicsPolyData() const
get geometric 3D description
void toolVisible(bool visible)
void tooltipOffset(double offset)
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:91
virtual Transform3D get_prMt() const
Definition: cxToolImpl.cpp:79
void tps(int)
virtual ProbePtr getProbe() const
additional information if the tool represents an US Probe. Extends getProbeSector() ...
virtual std::set< Type > getTypes() const
boost::shared_ptr< class Tool > ToolPtr