CustusX  2023.01.05-dev+develop.0da12
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
virtual void setVisible(bool vis)
if available for this type, set visibility
virtual bool getVisible() const
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
double getMilliSecondsSinceEpoch()
Definition: cxTime.cpp:44
virtual double getTooltipOffset() const
get a virtual offset extending from the tool tip.
Definition: cxToolImpl.cpp:65
virtual QString getName() const
virtual ~ManualTool()
ManualTool(const QString &uid, const QString &name="")
QString mUid
Definition: cxTool.h:149
virtual Transform3D getCalibration_sMt() const
get the calibration transform from tool space to sensor space (where the spheres or similar live) ...
void toolVisible(bool visible)
QString mName
Definition: cxTool.h:150
virtual void set_prMt(const Transform3D &prMt, double timestamp=-1)
void tooltipOffset(double offset)
virtual vtkPolyDataPtr getGraphicsPolyData() const
get geometric 3D description
virtual QString getUid() const
virtual int getIndex() const
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:85
virtual std::set< Type > getTypes() const
virtual bool isCalibrated() const
a tool may not be calibrated, then no tracking is allowed
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
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
Namespace for all CustusX production code.