NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxToolTreeNode.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 #include "cxToolTreeNode.h"
12 #include "cxTreeRepository.h"
13 #include "cxLogger.h"
14 #include "cxTrackingService.h"
15 #include "cxVisServices.h"
16 #include <QIcon>
17 #include <QFont>
18 #include <QLabel>
19 #include "cxToolPropertiesWidget.h"
21 
22 namespace cx
23 {
24 
25 
27  TreeNodeImpl(repo), mTool(tool)
28 {
29  connect(mTool.get(), &Tool::toolVisible, this, &TreeNode::changed);
30 
31 }
32 
34 {
35 }
36 
37 QString ToolTreeNode::getUid() const
38 {
39  return mTool->getUid();
40 }
41 
42 QString ToolTreeNode::getName() const
43 {
44  return mTool->getName();
45 }
46 
48 {
49  if (this->repo()->getMode()=="flat")
50  return this->repo()->getNodeForGroup("tool");
51 
52  if (mTool->getUid() == this->getServices()->tracking()->getManualTool()->getUid())
53  return this->repo()->getNode(CoordinateSystem(csPATIENTREF).toString());
54 
55  if (mTool->hasType(Tool::TOOL_REFERENCE))
56  return this->repo()->getNode(CoordinateSystem(csPATIENTREF).toString());
57 
58  ToolPtr ref = this->getServices()->tracking()->getReferenceTool();
59  if (ref)
60  return this->repo()->getNode(ref->getUid());
61 
62  return this->repo()->getNode(CoordinateSystem(csPATIENTREF).toString());
63 }
64 
66 {
67  this->getServices()->tracking()->setActiveTool(mTool->getUid());
68 }
69 
70 QString ToolTreeNode::getType() const
71 {
72  return "tool";
73 }
74 
75 QIcon ToolTreeNode::getIcon() const
76 {
77  if (mTool->hasType(Tool::TOOL_US_PROBE))
78  return QIcon(":icons/tool_us_probe.png");
79  if (mTool->hasType(Tool::TOOL_POINTER))
80  return QIcon(":icons/tool_pointer.png");
81  if (mTool->hasType(Tool::TOOL_REFERENCE))
82  return QIcon(":icons/tool_reference.png");
83  if (mTool->hasType(Tool::TOOL_MANUAL))
84  return QIcon(":icons/tool_manual.png");
85  return QIcon(":icons/tool_pointer.png");
86 }
87 
88 QVariant ToolTreeNode::getColor() const
89 {
90  if (!mTool->isInitialized())
91  return QColor("darkgray");
92  if (mTool->getVisible())
93  return QColor("green");
94  else
95  return QColor("red");
96 }
97 
98 QVariant ToolTreeNode::getFont() const
99 {
100  if (this->getServices()->tracking()->getActiveTool()==mTool)
101  {
102  QFont font;
103  font.setBold(true);
104  return font;
105  }
106  return QVariant();
107 }
108 
109 boost::shared_ptr<QWidget> ToolTreeNode::createPropertiesWidget() const
110 {
112  selector->setValue(mTool->getUid());
113  return boost::shared_ptr<QWidget>(new ToolPropertiesWidget(selector,
114  this->getServices()->tracking(),
115  this->getServices()->spaceProvider(),
116  NULL));
117 
118 // return new ToolPropertiesWidget(NULL);
119 // return new QLabel(QString("Tool widget %1 ").arg(mTool->getName()));
120 }
121 
122 
123 } // namespace cx
cx::ToolTreeNode::getType
virtual QString getType() const
Definition: cxToolTreeNode.cpp:70
cx::ToolPropertiesWidget
Definition: cxToolPropertiesWidget.h:56
cx::ToolTreeNode::getColor
virtual QVariant getColor() const
Definition: cxToolTreeNode.cpp:88
cxLogger.h
cx::TreeNodeImpl
Definition: cxTreeNodeImpl.h:26
cxTreeRepository.h
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
cxToolPropertiesWidget.h
cx::Tool::TOOL_POINTER
@ TOOL_POINTER
Navigation pointer. Pointing functionality such as tool offset.
Definition: cxTool.h:86
cx::ToolTreeNode::getName
virtual QString getName() const
Definition: cxToolTreeNode.cpp:42
cxStringPropertySelectTool.h
cx::ToolTreeNode::getIcon
virtual QIcon getIcon() const
Definition: cxToolTreeNode.cpp:75
cx::TreeNode::changed
void changed()
cx::Tool::TOOL_US_PROBE
@ TOOL_US_PROBE
Ultrasond probe. The tool has a Probe subinterface with a sector and a video stream.
Definition: cxTool.h:87
cx::ToolTreeNode::~ToolTreeNode
virtual ~ToolTreeNode()
Definition: cxToolTreeNode.cpp:33
cx::ToolTreeNode::activate
virtual void activate()
Definition: cxToolTreeNode.cpp:65
cx::TreeNodePtr
boost::shared_ptr< TreeNode > TreeNodePtr
Definition: cxDataTreeNode.h:22
cx::TreeNodeImpl::getServices
VisServicesPtr getServices() const
Definition: cxTreeNodeImpl.cpp:97
cx::ToolTreeNode::ToolTreeNode
ToolTreeNode(TreeRepositoryWeakPtr repo, ToolPtr tool)
Definition: cxToolTreeNode.cpp:26
cx::TreeNodeImpl::repo
TreeRepositoryPtr repo()
Definition: cxTreeNodeImpl.cpp:102
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cx::ToolTreeNode::getFont
virtual QVariant getFont() const
Definition: cxToolTreeNode.cpp:98
cx::ToolTreeNode::createPropertiesWidget
virtual boost::shared_ptr< QWidget > createPropertiesWidget() const
Definition: cxToolTreeNode.cpp:109
cx::StringPropertySelectTool::New
static StringPropertySelectToolPtr New(TrackingServicePtr trackingService)
Definition: cxStringPropertySelectTool.h:40
cx::ToolTreeNode::getUid
virtual QString getUid() const
Definition: cxToolTreeNode.cpp:37
cx::StringPropertySelectToolPtr
boost::shared_ptr< class StringPropertySelectTool > StringPropertySelectToolPtr
Definition: cxClipperWidget.h:27
csPATIENTREF
csPATIENTREF
the patient/tool reference space (pr)
Definition: cxDefinitions.h:92
cxTrackingService.h
cx::TreeRepositoryWeakPtr
boost::weak_ptr< class TreeRepository > TreeRepositoryWeakPtr
Definition: cxTreeNode.h:30
cxToolTreeNode.h
cx::ToolTreeNode::getParent
virtual TreeNodePtr getParent() const
Definition: cxToolTreeNode.cpp:47
cx::CoordinateSystem
Identification of a Coordinate system.
Definition: cxCoordinateSystemHelpers.h:31
cx::Tool::TOOL_REFERENCE
@ TOOL_REFERENCE
Reference tool.
Definition: cxTool.h:84
cxVisServices.h