CustusX  15.8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 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 
34 #include "cxManualTool.h"
35 #include <QTime>
36 #include <vtkSTLReader.h>
37 #include <vtkCursor3D.h>
38 #include "cxDummyTool.h"
39 
40 #include "cxTime.h"
41 
42 namespace cx
43 {
44 
45 ManualTool::ManualTool(const QString& uid, const QString& name) :
46  ToolImpl(uid, name)
47 {
48  mTimestamp = 0;
49  mVisible = false;
50  read3DCrossHairSlot(0);
51  connect(this, SIGNAL(tooltipOffset(double)), this, SLOT(read3DCrossHairSlot(double)));
52 }
53 
55 {
56 }
57 
58 void ManualTool::read3DCrossHairSlot(double toolTipOffset)
59 {
60  if (!mCrossHair)
61  {
62  mCrossHair = vtkCursor3DPtr::New();
63  mCrossHair->AllOff();
64  mCrossHair->AxesOn();
65  }
66  int s = 60;
67  mCrossHair->SetModelBounds(-s, s, -s, s, -s, s + toolTipOffset);
68  mCrossHair->SetFocalPoint(0, 0, toolTipOffset);
69  mCrossHair->Update();
70 }
71 
72 
75 void ManualTool::set_prMt(const Transform3D& prMt, double timestamp)
76 {
77  if (timestamp < 0)
78  timestamp = getMilliSecondsSinceEpoch();
79  mTimestamp = timestamp;
80  ToolImpl::set_prMt(prMt, timestamp);
81 }
82 
83 std::set<Tool::Type> ManualTool::getTypes() const
84 {
85  std::set<Type> retval;
86  retval.insert(Tool::TOOL_MANUAL);
87  return retval;
88 }
89 
90 
92 {
93  return mCrossHair->GetOutput();
94 }
95 
97 {
98  return mVisible;
99 }
100 
102 {
103  return -1;
104 }
105 
106 QString ManualTool::getUid() const
107 {
108  return mUid;
109 }
110 
111 QString ManualTool::getName() const
112 {
113  return mName;
114 }
115 
117 {
118  if (mVisible==vis)
119  return;
120  mVisible = vis;
121  emit toolVisible(mVisible);
122 }
123 
125 {
126  return false;
127 }
128 
130 {
131  return mTimestamp;
132 }
133 
135 {
136  return Transform3D::Identity();
137 }
138 
139 }//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:50
double getMilliSecondsSinceEpoch()
Definition: cxTime.cpp:65
virtual QString getName() const
virtual ~ManualTool()
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
Definition: cxProbeSector.h:47
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:91
virtual std::set< Type > getTypes() const
virtual bool isCalibrated() const
a tool may not be calibrated, then no tracking i allowed
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:84