CustusX  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
boost::shared_ptr< TreeNode > TreeNodePtr
void changed()
virtual QVariant getColor() const
virtual TreeNodePtr getParent() const
VisServicesPtr getServices() const
virtual QIcon getIcon() const
boost::shared_ptr< class StringPropertySelectTool > StringPropertySelectToolPtr
virtual void activate()
boost::weak_ptr< class TreeRepository > TreeRepositoryWeakPtr
Definition: cxTreeNode.h:30
TreeRepositoryPtr repo()
Reference tool.
Definition: cxTool.h:84
csPATIENTREF
the patient/tool reference space (pr)
Definition: cxDefinitions.h:90
void toolVisible(bool visible)
ToolTreeNode(TreeRepositoryWeakPtr repo, ToolPtr tool)
Identification of a Coordinate system.
Representation of a mouse/keyboard-controlled virtual tool.
Definition: cxTool.h:85
virtual QString getName() const
virtual QVariant getFont() const
static StringPropertySelectToolPtr New(TrackingServicePtr trackingService)
virtual ~ToolTreeNode()
virtual boost::shared_ptr< QWidget > createPropertiesWidget() const
virtual QString getUid() const
virtual QString getType() const
Ultrasond probe. The tool has a Probe subinterface with a sector and a video stream.
Definition: cxTool.h:87
Navigation pointer. Pointing functionality such as tool offset.
Definition: cxTool.h:86
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr