NorMIT-nav  22.09
An IGT application
cxToolProperty.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 #include "cxToolProperty.h"
13 
14 #include "cxTypeConversions.h"
15 #include "cxTrackingService.h"
16 #include "cxTool.h"
17 
18 namespace cx
19 {
20 
21 
23 {
24  mTrackingService = trackingService;
25  connect(mTrackingService.get(), SIGNAL(activeToolChanged(const QString&)), this, SIGNAL(changed()));
26  connect(mTrackingService.get(), &TrackingService::stateChanged, this, &StringPropertyActiveTool::changed);
27 }
28 
30 {
31  return "Active Tool";
32 }
33 
34 bool StringPropertyActiveTool::setValue(const QString& value)
35 {
36  ToolPtr newTool = mTrackingService->getTool(value);
37  if (!newTool)
38  return false;
39  if(newTool == mTrackingService->getActiveTool())
40  return false;
41  mTrackingService->setActiveTool(newTool->getUid());
42  return true;
43 }
44 
46 {
47  if (!mTrackingService->getActiveTool())
48  return "";
49  return qstring_cast(mTrackingService->getActiveTool()->getUid());
50 }
51 
53 {
54  return "select the active tool";
55 }
56 
58 {
59  TrackingService::ToolMap tools = mTrackingService->getTools();
60 
61  QStringList retval;
62  for (TrackingService::ToolMap::iterator iter=tools.begin(); iter!=tools.end(); ++iter)
63  retval << iter->second->getUid();
64  return retval;
65 }
66 
68 {
69  ToolPtr tool = mTrackingService->getTool(internal);
70  if (!tool)
71  return "<no tool>";
72  return qstring_cast(tool->getName());
73 }
74 
75 //--------------------------------------------------------
76 //--------------------------------------------------------
77 //--------------------------------------------------------
78 
80 {
81  mTrackingService = trackingService;
82  connect(mTrackingService.get(), &TrackingService::activeToolChanged, this, &StringPropertyActiveProbeConfiguration::activeToolChanged);
83  connect(mTrackingService.get(), &TrackingService::stateChanged, this, &StringPropertyActiveProbeConfiguration::activeToolChanged);
84  this->activeToolChanged();
85 }
86 
87 void StringPropertyActiveProbeConfiguration::activeToolChanged()
88 {
89  // ignore tool changes to something non-probeish.
90  // This gives the user a chance to use the widget without having to show the probe.
91  ToolPtr newTool = mTrackingService->getFirstProbe();
92  if (!newTool || !newTool->getProbe())
93  return;
94 
95  if (mTool)
96  disconnect(mTool->getProbe().get(), &Probe::sectorChanged, this, &StringPropertyActiveProbeConfiguration::changed);
97 
98  mTool = newTool;
99 
100  if (mTool)
101  connect(mTool->getProbe().get(), &Probe::sectorChanged, this, &StringPropertyActiveProbeConfiguration::changed);
102 
103  emit changed();
104 }
105 
107 {
108  return "Probe Config";
109 }
110 
112 {
113  if (!mTool)
114  return false;
115  mTool->getProbe()->applyNewConfigurationWithId(value);
116  return true;
117 }
118 
120 {
121  if (!mTool)
122  return "";
123  return mTool->getProbe()->getConfigId();
124 }
125 
127 {
128  return "Select a probe configuration for the active probe.";
129 }
130 
132 {
133  if (!mTool)
134  return QStringList();
135  return mTool->getProbe()->getConfigIdList();
136 }
137 
139 {
140  if (!mTool)
141  return "<no tool>";
142  return mTool->getProbe()->getConfigName(internal);
143 }
144 
145 
146 }
cx::StringPropertyActiveTool::convertInternal2Display
virtual QString convertInternal2Display(QString internal)
Definition: cxToolProperty.cpp:67
cx::StringPropertyActiveTool::getValueRange
virtual QStringList getValueRange() const
Definition: cxToolProperty.cpp:57
qstring_cast
QString qstring_cast(const T &val)
Definition: cxTypeConversions.h:46
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::Property::changed
void changed()
emit when the underlying data value is changed: The user interface will be updated.
cx::StringPropertyActiveTool::setValue
virtual bool setValue(const QString &value)
set the data value.
Definition: cxToolProperty.cpp:34
cx::StringPropertyActiveProbeConfiguration::StringPropertyActiveProbeConfiguration
StringPropertyActiveProbeConfiguration(TrackingServicePtr trackingService)
Definition: cxToolProperty.cpp:79
cxToolProperty.h
cx::StringPropertyActiveTool::getHelp
virtual QString getHelp() const
Definition: cxToolProperty.cpp:52
cx::Probe::sectorChanged
void sectorChanged()
< Return a ProbeSectorPtr for the given uid. Use 'active' to get the default.
cx::TrackingServicePtr
boost::shared_ptr< class TrackingService > TrackingServicePtr
Definition: cxToolFilterWidget.h:27
cx::StringPropertyActiveProbeConfiguration::getValue
virtual QString getValue() const
get the data value.
Definition: cxToolProperty.cpp:119
cxTool.h
cxTypeConversions.h
cx::StringPropertyActiveTool::getValue
virtual QString getValue() const
get the data value.
Definition: cxToolProperty.cpp:45
cx::StringPropertyActiveTool::getDisplayName
virtual QString getDisplayName() const
name of data entity. Used for display to user.
Definition: cxToolProperty.cpp:29
cx::TrackingService::stateChanged
void stateChanged()
cx::TrackingService::activeToolChanged
void activeToolChanged(const QString &uId)
cx::StringPropertyActiveProbeConfiguration::getHelp
virtual QString getHelp() const
Definition: cxToolProperty.cpp:126
cx::StringPropertyActiveProbeConfiguration::getValueRange
virtual QStringList getValueRange() const
Definition: cxToolProperty.cpp:131
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cx::StringPropertyActiveProbeConfiguration::convertInternal2Display
virtual QString convertInternal2Display(QString internal)
Definition: cxToolProperty.cpp:138
cx::StringPropertyActiveProbeConfiguration::setValue
virtual bool setValue(const QString &value)
set the data value.
Definition: cxToolProperty.cpp:111
cxTrackingService.h
cx::StringPropertyActiveProbeConfiguration::getDisplayName
virtual QString getDisplayName() const
name of data entity. Used for display to user.
Definition: cxToolProperty.cpp:106
cx::TrackingService::ToolMap
std::map< QString, ToolPtr > ToolMap
Definition: cxTrackingService.h:54
cx::StringPropertyActiveTool::StringPropertyActiveTool
StringPropertyActiveTool(TrackingServicePtr trackingService)
Definition: cxToolProperty.cpp:22