Fraxinus  16.5.0-fx-rc5
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 #include <QTimer>
35 
36 namespace cx
37 {
38 
40  ManualTool(uid)
41 {
42  ToolPtr initial(new ManualTool(uid + "base"));
43  this->setBase(initial);
44 // mBase.reset(new ManualTool(uid + "base"));
45 // connect(mBase.get(), SIGNAL(toolProbeSector()), this, SIGNAL(toolProbeSector()));
46 }
47 
49  ManualTool(mBase->getUid() + "_manual"), mBase(base)
50 {
51 }
52 
54 {
55 }
56 
58 {
59  if (mBase)
60  {
61  disconnect(mBase.get(), &Tool::toolTransformAndTimestamp, this, &Tool::toolTransformAndTimestamp);
62  disconnect(mBase.get(), &Tool::toolVisible, this, &Tool::toolVisible);
63  disconnect(mBase.get(), &Tool::tooltipOffset, this, &Tool::tooltipOffset);
64  disconnect(mBase.get(), &Tool::toolProbeSector, this, &Tool::toolProbeSector);
65  disconnect(mBase.get(), &Tool::tps, this, &Tool::tps);
66  }
67 
68  mBase = base;
69 
70  if (mBase)
71  {
73  connect(mBase.get(), &Tool::toolVisible, this, &Tool::toolVisible);
74  connect(mBase.get(), &Tool::tooltipOffset, this, &Tool::tooltipOffset);
75  connect(mBase.get(), &Tool::toolProbeSector, this, &Tool::toolProbeSector);
76  connect(mBase.get(), &Tool::tps, this, &Tool::tps);
77  }
78 
79  emit toolVisible(this->getVisible());
80  emit toolTransformAndTimestamp(this->get_prMt(), this->getTimestamp());
81  emit tooltipOffset(this->getTooltipOffset());
82  emit toolProbeSector();
83  emit tps(0);
84 }
85 
87 {
88  return mBase->getGraphicsPolyData();
89 }
90 
92 {
93  return mBase->isCalibrated();
94 }
95 
97 {
98  return mBase->getProbe();
99 }
100 
102 {
103  return mBase->getCalibration_sMt();
104 }
105 
106 std::map<int, Vector3D> ManualToolAdapter::getReferencePoints() const
107 {
108  return mBase->getReferencePoints();
109 }
110 
112 {
113  return mBase->getTooltipOffset();
114 }
115 
117 {
118  mBase->setTooltipOffset(val);
119 }
120 
121 std::set<Tool::Type> ManualToolAdapter::getTypes() const
122 {
123  std::set<Tool::Type> retval = mBase->getTypes();
124  retval.insert(Tool::TOOL_MANUAL);
125  return retval;
126 }
127 
129 {
130  QTimer* positionTimer = new QTimer(this);
131  connect(positionTimer, SIGNAL(timeout()), this, SLOT(emitPosition()));
132  positionTimer->start(msecBetweenPositions);
133 }
134 
135 //Not used for now
136 //void ManualToolAdapter::stopEmittingContinuousPositions()
137 //{
138 // positionTimer->stop();
139 //}
140 
141 void ManualToolAdapter::emitPosition()
142 {
144 }
145 
146 }
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)
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
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
void toolVisible(bool visible)
void tooltipOffset(double offset)
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:106
virtual Transform3D get_prMt() const
Definition: cxToolImpl.cpp:92
void tps(int)
virtual ProbePtr getProbe() const
additional information if the tool represents an US Probe. Extends getProbeSector() ...
void startEmittingContinuousPositions(int msecBetweenPositions)
virtual std::set< Type > getTypes() const
Transform3D m_prMt
the transform from the tool to the patient reference
Definition: cxToolImpl.h:76
boost::shared_ptr< class Tool > ToolPtr