NorMIT-nav  22.09
An IGT application
cxManualTool.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) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 
13 #include "cxManualTool.h"
14 #include <QTime>
15 #include <vtkSTLReader.h>
16 #include <vtkCursor3D.h>
17 #include "cxDummyTool.h"
18 
19 #include "cxTime.h"
20 
21 namespace cx
22 {
23 
24 ManualTool::ManualTool(const QString& uid, const QString& name) :
25  ToolImpl(uid, name)
26 {
27  mTimestamp = 0;
28  mVisible = false;
29  // read3DCrossHairSlot(0);
30  connect(this, SIGNAL(tooltipOffset(double)), this, SLOT(read3DCrossHairSlot(double)));
31 }
32 
34 {
35 }
36 
37 void ManualTool::read3DCrossHairSlot(double toolTipOffset) const
38 {
39  if (!mCrossHair)
40  return;
41  this->update3DCrossHair(toolTipOffset);
42 }
43 
44 void ManualTool::update3DCrossHair(double toolTipOffset) const
45 {
46  if (!mCrossHair)
47  {
48  mCrossHair = vtkCursor3DPtr::New();
49  mCrossHair->AllOff();
50  mCrossHair->AxesOn();
51  }
52  int s = 60;
53  mCrossHair->SetModelBounds(-s, s, -s, s, -s, s + toolTipOffset);
54  mCrossHair->SetFocalPoint(0, 0, toolTipOffset);
55  mCrossHair->Update();
56 }
57 
58 
61 void ManualTool::set_prMt(const Transform3D& prMt, double timestamp)
62 {
63  if (timestamp < 0)
64  timestamp = getMilliSecondsSinceEpoch();
65  mTimestamp = timestamp;
66  ToolImpl::set_prMt(prMt, timestamp);
67 }
68 
69 std::set<Tool::Type> ManualTool::getTypes() const
70 {
71  std::set<Type> retval;
72  retval.insert(Tool::TOOL_MANUAL);
73  return retval;
74 }
75 
76 
78 {
79  this->update3DCrossHair(this->getTooltipOffset());
80  return mCrossHair->GetOutput();
81 }
82 
84 {
85  return mVisible;
86 }
87 
89 {
90  return -1;
91 }
92 
93 QString ManualTool::getUid() const
94 {
95  return mUid;
96 }
97 
98 QString ManualTool::getName() const
99 {
100  return mName;
101 }
102 
104 {
105  if (mVisible==vis)
106  return;
107  mVisible = vis;
108  emit toolVisible(mVisible);
109 }
110 
112 {
113  return false;
114 }
115 
117 {
118  return mTimestamp;
119 }
120 
122 {
123  return Transform3D::Identity();
124 }
125 
126 }//end namespace
cx::ManualTool::getCalibration_sMt
virtual Transform3D getCalibration_sMt() const
get the calibration transform from tool space to sensor space (where the spheres or similar live)
Definition: cxManualTool.cpp:121
cx::ManualTool::getUid
virtual QString getUid() const
Definition: cxManualTool.cpp:93
cx::ManualTool::getName
virtual QString getName() const
Definition: cxManualTool.cpp:98
cx::Tool::toolVisible
void toolVisible(bool visible)
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::Tool::TOOL_MANUAL
@ TOOL_MANUAL
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:85
cx::ManualTool::getVisible
virtual bool getVisible() const
Definition: cxManualTool.cpp:83
cx::getMilliSecondsSinceEpoch
double getMilliSecondsSinceEpoch()
Definition: cxTime.cpp:44
cx::ManualTool::set_prMt
virtual void set_prMt(const Transform3D &prMt, double timestamp=-1)
Definition: cxManualTool.cpp:61
cx::ToolImpl::getTooltipOffset
virtual double getTooltipOffset() const
Definition: cxToolImpl.cpp:65
cxDummyTool.h
cx::ManualTool::getGraphicsPolyData
virtual vtkPolyDataPtr getGraphicsPolyData() const
get geometric 3D description
Definition: cxManualTool.cpp:77
cx::ManualTool::getTypes
virtual std::set< Type > getTypes() const
Definition: cxManualTool.cpp:69
cx::ManualTool::isCalibrated
virtual bool isCalibrated() const
a tool may not be calibrated, then no tracking is allowed
Definition: cxManualTool.cpp:111
cxManualTool.h
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cx::ManualTool::~ManualTool
virtual ~ManualTool()
Definition: cxManualTool.cpp:33
cx::Tool::mUid
QString mUid
Definition: cxTool.h:149
cx::ManualTool::ManualTool
ManualTool(const QString &uid, const QString &name="")
Definition: cxManualTool.cpp:24
cx::ManualTool::getTimestamp
virtual double getTimestamp() const
latest valid timestamp for the position matrix. 0 means indeterminate (for f.ex. manual tools)
Definition: cxManualTool.cpp:116
cx::vtkPolyDataPtr
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
Definition: cxCenterlineRegistration.h:42
cx::Tool::tooltipOffset
void tooltipOffset(double offset)
cxTime.h
cx::ToolImpl::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: cxToolImpl.cpp:102
cx::ToolImpl
Common functionality for Tool subclasses.
Definition: cxToolImpl.h:30
cx::Tool::mName
QString mName
Definition: cxTool.h:150
cx::ManualTool::getIndex
virtual int getIndex() const
Definition: cxManualTool.cpp:88
cx::ManualTool::setVisible
virtual void setVisible(bool vis)
if available for this type, set visibility
Definition: cxManualTool.cpp:103