Fraxinus  16.5.0-fx-rc9
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) const
59 {
60  if (!mCrossHair)
61  return;
62  this->update3DCrossHair(toolTipOffset);
63 }
64 
65 void ManualTool::update3DCrossHair(double toolTipOffset) const
66 {
67  if (!mCrossHair)
68  {
69  mCrossHair = vtkCursor3DPtr::New();
70  mCrossHair->AllOff();
71  mCrossHair->AxesOn();
72  }
73  int s = 60;
74  mCrossHair->SetModelBounds(-s, s, -s, s, -s, s + toolTipOffset);
75  mCrossHair->SetFocalPoint(0, 0, toolTipOffset);
76  mCrossHair->Update();
77 }
78 
79 
82 void ManualTool::set_prMt(const Transform3D& prMt, double timestamp)
83 {
84  if (timestamp < 0)
85  timestamp = getMilliSecondsSinceEpoch();
86  mTimestamp = timestamp;
87  ToolImpl::set_prMt(prMt, timestamp);
88 }
89 
90 std::set<Tool::Type> ManualTool::getTypes() const
91 {
92  std::set<Type> retval;
93  retval.insert(Tool::TOOL_MANUAL);
94  return retval;
95 }
96 
97 
99 {
100  this->update3DCrossHair(0);
101  return mCrossHair->GetOutput();
102 }
103 
105 {
106  return mVisible;
107 }
108 
110 {
111  return -1;
112 }
113 
114 QString ManualTool::getUid() const
115 {
116  return mUid;
117 }
118 
119 QString ManualTool::getName() const
120 {
121  return mName;
122 }
123 
125 {
126  if (mVisible==vis)
127  return;
128  mVisible = vis;
129  emit toolVisible(mVisible);
130 }
131 
133 {
134  return false;
135 }
136 
138 {
139  return mTimestamp;
140 }
141 
143 {
144  return Transform3D::Identity();
145 }
146 
147 }//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()
ManualTool(const QString &uid, const QString &name="")
QString mUid
Definition: cxTool.h:168
virtual Transform3D getCalibration_sMt() const
get the calibration transform from tool space to sensor space (where the spheres or similar live) ...
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
void toolVisible(bool visible)
QString mName
Definition: cxTool.h:169
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:106
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:97